.count( [criteria, ] callback )

Purpose

Returns the number of records in your database that meet the given search criteria.

Overview

Parameters

# Description Accepted Data Types Required ?
1 Find Criteria {},[{}], string, int No
2 Callback function No

Callback Parameters

# Description Possible Data Types
1 Error Error
2 Number of Records int

Example Usage

  1. User.count({name:'Flynn'}).exec(function countCB(error, found) {
  2. console.log('There are ' + found + ' users called "Flynn"');
  3. // There are 1 users called 'Flynn'
  4. // Don't forget to handle your errors
  5. });

Notes

Any string arguments passed must be the ID of the record.