Reputation: 16055
I find this a bit confusing. In one case, you have:
return MyData.find({}, {sort: {size: 1}});
But then in another case:
MyData.update(objId, {$inc: {size: 5}});
Why isn't $sort
used above? How do I know when to use $
or not?
Upvotes: 0
Views: 39
Reputation: 151132
Well there is a whole section in the documentation that tells you which which "operators" can be used with each separate type of operation.
The basic case is that the $
prefixed items are "operators", or otherwise possibly "variables" within the context of aggregation pipeline stages.
The second document syntax of "sort" is actually specific to "minimongo" in it's choice of how to issue a "sort" modifier to a query. In all other cases the referenced document will apply as to whether this is used with .find()
or .update()
or .aggregate()
in the respective operations.
Upvotes: 1