mongoose count code example
Example 1: mongoose count documents
await model.countDocuments({ name: 'Florin' })
Example 2: mongo count
db.collection.countDocuments( <query>, <options> )
Example 3: mongoose count
model.estimatedDocumentCount();
Example 4: mongoose select
query.select('a b');
query.select(['a', 'b']);
query.select({ a: 1, b: 1 });
query.select('-c -d');
const schema = new Schema({
foo: { type: String, select: false },
bar: String
});
query.select('+foo');
query.select({ a: 1, b: 1 });
query.select({ c: 0, d: 0 });
Example 5: countDocuments mongoose
Adventure.countDocuments({ type: 'jungle' }, function (err, count) {
console.log('there are %d jungle adventures', count);
});