Created
October 7, 2022 14:49
-
-
Save kevcodez/9bf4222578b70d556a9f8b641dc7e5b4 to your computer and use it in GitHub Desktop.
medium_mongodb_performance_merge
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
db.holdings.aggregate([ | |
{ | |
$group: { | |
_id: '$portfolio', | |
assetIdentifiers: { | |
$addToSet: '$asset.identifier', | |
}, | |
}, | |
}, | |
{ | |
$merge: { | |
into: 'portfolio_assets', | |
whenMatched: 'replace', | |
}, | |
}, | |
]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment