Limiting results in MongoDB but still getting the full count?

By default, count() ignores limit() and counts the results in the entire query.
So when you for example do this, var a = db.collection.find(...).limit(10);
running a.count() will give you the total count of your query.

Leave a Comment