Last active
November 3, 2015 19:45
-
-
Save AlexFrazer/13b138e2ebf1a6fd3d0e to your computer and use it in GitHub Desktop.
This file contains 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
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" | |
}] | |
} | |
}] | |
} |
This file contains 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
{ | |
"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