Skip to content

Instantly share code, notes, and snippets.

@davetapley
Last active December 16, 2015 02:59
Show Gist options
  • Save davetapley/5366519 to your computer and use it in GitHub Desktop.
Save davetapley/5366519 to your computer and use it in GitHub Desktop.
Count for mongojs cursor is returned incorrectly.
var testCollection = require('mongojs')('test').collection('testCollection'),
shouldBeOneDoc = testCollection.find({}).sort({ myField : 1 }).limit(1);
shouldBeOneDoc.count(function (err, count) { console.log(count) });
@davetapley
Copy link
Author

If testCollection has more than one document, the count will be the total number of documents, seemingly disregarding the limit(1).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment