lib/operations/db_ops.js
function indexInformation(db, name, options, callback) {
  // If we specified full information
  const full = options['full'] == null ? false : options['full'];

  // Did the user destroy the topology
  if (db.serverConfig && db.serverConfig.isDestroyed())
    return callback(new MongoError('topology was destroyed'));
  // Process all the results from the index command and collection
  function processResults(indexes) {
    // Contains all the information
    let info = {};
    // Process all the indexes
    for (let i = 0; i < indexes.length; i++) {
      const index = indexes[i];
      // Let's unpack the object
      info[index.name] = [];
      for (let name in index.key) {
        info[index.name].push([name, index.key[name]]);
      }
    }

    return info;
  }

  // Get the list of indexes of the specified collection
  db
    .collection(name)
    .listIndexes(options)
    .toArray((err, indexes) => {
      if (err) return callback(toError(err));
      if (!Array.isArray(indexes)) return handleCallback(callback, null, []);
      if (full) return handleCallback(callback, null, indexes);
      handleCallback(callback, null, processResults(indexes));
    });
}
function indexInformation(db, name, options, callback) {
  // If we specified full information
  const full = options['full'] == null ? false : options['full'];

  // Did the user destroy the topology
  if (db.serverConfig && db.serverConfig.isDestroyed())
    return callback(new MongoError('topology was destroyed'));
  // Process all the results from the index command and collection
  function processResults(indexes) {
    // Contains all the information
    let info = {};
    // Process all the indexes
    for (let i = 0; i < indexes.length; i++) {
      const index = indexes[i];
      // Let's unpack the object
      info[index.name] = [];
      for (let name in index.key) {
        info[index.name].push([name, index.key[name]]);
      }
    }

    return info;
  }

  // Get the list of indexes of the specified collection
  db
    .collection(name)
    .listIndexes(options)
    .toArray((err, indexes) => {
      if (err) return callback(toError(err));
      if (!Array.isArray(indexes)) return handleCallback(callback, null, []);
      if (full) return handleCallback(callback, null, indexes);
      handleCallback(callback, null, processResults(indexes));
    });
}
function indexInformation ( db , name , options , callback ) { // If we specified full information const full = options [ 'full' ] == null ? false : options [ 'full' ] ; // Did the user destroy the topology if ( db . serverConfig && db . serverConfig . isDestroyed ( ) ) return callback ( new MongoError ( 'topology was destroyed' ) ) ; // Process all the results from the index command and collection function processResults ( indexes ) { // Contains all the information let info = { } ; // Process all the indexes for ( let i = 0 ; i < indexes . length ; i ++ ) { const index = indexes [ i ] ; // Let's unpack the object info [ index . name ] = [ ] ; for ( let name in index . key ) { info [ index . name ] . push ( [ name , index . key [ name ] ] ) ; } } return info ; } // Get the list of indexes of the specified collection db . collection ( name ) . listIndexes ( options ) . toArray ( ( err , indexes ) => { if ( err ) return callback ( toError ( err ) ) ; if ( ! Array . isArray ( indexes ) ) return handleCallback ( callback , null , [ ] ) ; if ( full ) return handleCallback ( callback , null , indexes ) ; handleCallback ( callback , null , processResults ( indexes ) ) ; } ) ; }
Retrieves this collections index info.

@method
@param {Db} db The Db instance on which to retrieve the index info.
@param {string} name The name of the collection.
@param {object} [options] Optional settings. See Db.prototype.indexInformation for a list of options.
@param {Db~resultCallback} [callback] The command result callback
Retrieves this collections index info .