Last active
December 12, 2015 10:09
-
-
Save xosofox/4756807 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (Meteor.isServer) { | |
// update the appropriate rsvp entry with $ | |
Parties.update( | |
{_id: partyId, "rsvps.user": this.userId}, | |
{$set: {"rsvps.$.rsvp": rsvp}}); | |
} else { | |
// minimongo doesn't yet support $ in modifier. as a temporary | |
// workaround, make a modifier that uses an index. this is | |
// safe on the client since there's only one thread. | |
var modifier = {$set: {}}; | |
modifier.$set["rsvps." + rsvpIndex + ".rsvp"] = rsvp; | |
Parties.update(partyId, modifier); | |
} | |
} |
- What is the $ in line 5? An index? But how is it defined? Where can I find more details on that in the mongo docs?
http://docs.mongodb.org/manual/reference/operator/positional/
- How is the workaround on the client side working? A $set on a $set?
Looks like a workaround for the minimongo library's overly strict validation of find()
and update()
arguments. Perhaps it complains about using $
as a component in a field path.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I would need some help on the "Black Mongo Magic" that is going on here: