Reputation: 614
I've noticed a few instances within the node MongoDB driver where one can perform a cursor operation either through an options
parameter or through a chained method, as shown below. Do these perform the same operation or is there some difference (e.g. performance characteristics) between the two?
This example uses sort
though the same applies in other cases as well (e.g. limit
). First, as an options parameter:
db.collection.find({}, {sort: {_id: 1}})
Now, as a chained cursor method:
db.collection.find({}).sort({_id: 1})
Upvotes: 2
Views: 84