lib/operations/collection_ops.js
function indexExists(coll, indexes, options, callback) {
  indexInformation(coll, options, (err, indexInformation) => {
    // If we have an error return
    if (err != null) return handleCallback(callback, err, null);
    // Let's check for the index names
    if (!Array.isArray(indexes))
      return handleCallback(callback, null, indexInformation[indexes] != null);
    // Check in list of indexes
    for (let i = 0; i < indexes.length; i++) {
      if (indexInformation[indexes[i]] == null) {
        return handleCallback(callback, null, false);
      }
    }

    // All keys found return true
    return handleCallback(callback, null, true);
  });
}
function indexExists(coll, indexes, options, callback) {
  indexInformation(coll, options, (err, indexInformation) => {
    // If we have an error return
    if (err != null) return handleCallback(callback, err, null);
    // Let's check for the index names
    if (!Array.isArray(indexes))
      return handleCallback(callback, null, indexInformation[indexes] != null);
    // Check in list of indexes
    for (let i = 0; i < indexes.length; i++) {
      if (indexInformation[indexes[i]] == null) {
        return handleCallback(callback, null, false);
      }
    }

    // All keys found return true
    return handleCallback(callback, null, true);
  });
}
function indexExists ( coll , indexes , options , callback ) { indexInformation ( coll , options , ( err , indexInformation ) => { // If we have an error return if ( err != null ) return handleCallback ( callback , err , null ) ; // Let's check for the index names if ( ! Array . isArray ( indexes ) ) return handleCallback ( callback , null , indexInformation [ indexes ] != null ) ; // Check in list of indexes for ( let i = 0 ; i < indexes . length ; i ++ ) { if ( indexInformation [ indexes [ i ] ] == null ) { return handleCallback ( callback , null , false ) ; } } // All keys found return true return handleCallback ( callback , null , true ) ; } ) ; }
Check if one or more indexes exist on the collection. This fails on the first index that doesn't exist.

@method
@param {Collection} a Collection instance.
@param {(string|array)} indexes One or more index names to check.
@param {Object} [options] Optional settings. See Collection.prototype.indexExists for a list of options.
@param {Collection~resultCallback} [callback] The command result callback
Check if one or more indexes exist on the collection . This fails on the first index that doesn t exist .