Model.count()

Parameters
  • filter «Object»
  • [callback] «Function»
Returns:
  • «Query»

Counts number of documents that match filter in a database collection.

This method is deprecated. If you want to count the number of documents in a collection, e.g. count({}), use the estimatedDocumentCount() function instead. Otherwise, use the countDocuments() function instead.

Example:

  1. Adventure.count({ type: 'jungle' }, function (err, count) {
  2. if (err) ..
  3. console.log('there are %d jungle adventures', count);
  4. });