Reputation: 1550
Meteor seems to be missing the $max update operator.
I'm following the documentation here in the meteor mongo shell:
meteor:PRIMARY> db.vesrion()
2.4.9
meteor:PRIMARY> db.scores.insert({ _id: 1, highScore: 800, lowScore: 200 })
meteor:PRIMARY> db.scores.find()
{ "_id" : 1, "highScore" : 800, "lowScore" : 200 }
meteor:PRIMARY> db.scores.update( { _id: 1 }, { $max: { highScore: 950 } } )
Invalid modifier specified $max
Is there something I'm doing wrong? I can simulate the $max behavior by adding $lt clauses to my update condition, but it's clunky and doesn't work well if I also want to update other fields (for example, increment numGamesPlayed by 1 while also updating highScore).
Upvotes: 2
Views: 281
Reputation: 311855
There's nothing you're doing wrong, the problem is that the $max
update operator was added in 2.6.
If you click the 2.6 (current)
in the upper left of that doc page and select version 2.4 docs instead you'll see that $max
is not there.
The best reference I can find is in the 2.6 release notes.
Upvotes: 2