AshokGK
AshokGK

Reputation: 875

Difference between sort with aggregation and sort with find

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

Answers (1)

RRPatel
RRPatel

Reputation: 39

sort() applies to the documents that are being returned.

$sort applies to all of the element inside of such documents.

Upvotes: 1

Related Questions