Created
August 4, 2023 10:43
-
-
Save ricardocasares/94cc81085d8cfef1798ba3096b1f6c81 to your computer and use it in GitHub Desktop.
aggregate by highest semver
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.getCollection("versioned").aggregate( | |
[ | |
{ $sort: { __version: -1 }}, | |
{ $group: { _id: "$UUID", doc: { $first: "$$ROOT" }}}, | |
{ $replaceWith: "$doc" } | |
], | |
{ collation: { locale: 'en', numericOrdering: true }} | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment