Counting documents

You can use count to count documents. It has the same syntax as find. For example:

  1. // Count all planets in the solar system
  2. db.count({ system: 'solar' }, function (err, count) {
  3. // count equals to 3
  4. });
  5. // Count all documents in the datastore
  6. db.count({}, function (err, count) {
  7. // count equals to 4
  8. });