db.getCollection('posts').find({}, {sort: {post_id: 1}})
is returning
error: {
"$err" : "Can't canonicalize query: BadValue Unsupported projection option: sort: { post_id: 1.0 }",
"code" : 17287
}
I'm baffled because I've run queries almost exactly like this in the past. I'm running it through Robomongo but it does not work from my Meteor application either. Can anybody explain what's going on?
Within Meteor the syntax is nearly as you've used:
YourCollection.find({}, {sort: {post_id: 1}})
With the MongoDB shell the format is like this:
db.posts.find({}).sort({post_id: 1})
You may still get an error at this point if you have too many results, to which you can add a limit:
db.posts.find({}).sort({post_id: 1}).limit(20)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With