Mongoose Model.count() does not run callback as documented

mongodb, mongoose, node.js

Solution

Make sure you've connected to the database before calling any model functions. Mongoose will just queue up the `count` query until you connect otherwise.

See this question of the FAQ.

Problem

I am following almost the exact example for Model.count() from the Mongoose docs: ``` User.count({ type: 'jungle' }, function (err, count) { console.log('I do not ever run'); }); ``` This should print 'I do not ever run'. Instead, it returns a Query object - which should not happen, according to the docs, as I am providing a callback. How can I make the callback function run? Is there some circumstances where the callback is not run? Using mongoose@3.6.17. Thanks!

Original source