Reputation: 875
Is there any difference between following two queries, please explain
db.grades.aggregate([{$sort: {type:1 score:1 } }])
and
db.grades.find().sort({type:1, score:1})
I got the same result when I run these queries, please explain functional and performance differences
Thanks
Upvotes: 3
Views: 385
Reputation: 39
sort()
applies to the documents that are being returned.
$sort
applies to all of the element inside of such documents.
Upvotes: 1