Skip to content

Instantly share code, notes, and snippets.

@AlexFrazer
Last active November 3, 2015 19:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlexFrazer/13b138e2ebf1a6fd3d0e to your computer and use it in GitHub Desktop.
Save AlexFrazer/13b138e2ebf1a6fd3d0e to your computer and use it in GitHub Desktop.
findAndReplace('games.$._id', obj, function (key, value) {
return Collections['games'].findOne(value);
});
// expected result:
{
"battletag": "corvid#1376",
"games": [{
"overwatch": {
"characters": [{
"_id": "1234",
"class": "Hanzo",
"league": "Diamond"
}, {
"_id": "5678",
"class": "Widowmaker",
"league": "Diamond"
}]
}
}, {
"world of warcraft": {
"characters": [{
"_id": "234",
"name": "Corvid",
"class": "Shaman",
"league": "Bronze"
}]
}
}]
}
{
"battletag": "corvid#1376",
"games": [{
"overwatch": {
"characters": [{
"_id": "1234",
}, {
"_id": "5678",
}]
}
}, {
"world of warcraft": {
"characters": [{
"_id": "234",
}]
}
}]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment