lib/operations/db_ops.js
function collections(db, options, callback) {
  let Collection = loadCollection();

  options = Object.assign({}, options, { nameOnly: true });
  // Let's get the collection names
  db.listCollections({}, options).toArray((err, documents) => {
    if (err != null) return handleCallback(callback, err, null);
    // Filter collections removing any illegal ones
    documents = documents.filter(doc => {
      return doc.name.indexOf('$') === -1;
    });

    // Return the collection objects
    handleCallback(
      callback,
      null,
      documents.map(d => {
        return new Collection(
          db,
          db.s.topology,
          db.s.databaseName,
          d.name,
          db.s.pkFactory,
          db.s.options
        );
      })
    );
  });
}
function collections(db, options, callback) {
  let Collection = loadCollection();

  options = Object.assign({}, options, { nameOnly: true });
  // Let's get the collection names
  db.listCollections({}, options).toArray((err, documents) => {
    if (err != null) return handleCallback(callback, err, null);
    // Filter collections removing any illegal ones
    documents = documents.filter(doc => {
      return doc.name.indexOf('$') === -1;
    });

    // Return the collection objects
    handleCallback(
      callback,
      null,
      documents.map(d => {
        return new Collection(
          db,
          db.s.topology,
          db.s.databaseName,
          d.name,
          db.s.pkFactory,
          db.s.options
        );
      })
    );
  });
}
function collections ( db , options , callback ) { let Collection = loadCollection ( ) ; options = Object . assign ( { } , options , { nameOnly : true } ) ; // Let's get the collection names db . listCollections ( { } , options ) . toArray ( ( err , documents ) => { if ( err != null ) return handleCallback ( callback , err , null ) ; // Filter collections removing any illegal ones documents = documents . filter ( doc => { return doc . name . indexOf ( '$' ) === - 1 ; } ) ; // Return the collection objects handleCallback ( callback , null , documents . map ( d => { return new Collection ( db , db . s . topology , db . s . databaseName , d . name , db . s . pkFactory , db . s . options ) ; } ) ) ; } ) ; }
Fetch all collections for the current db.

@method
@param {Db} db The Db instance on which to fetch collections.
@param {object} [options] Optional settings. See Db.prototype.collections for a list of options.
@param {Db~collectionsResultCallback} [callback] The results callback
Fetch all collections for the current db .