Created
July 21, 2019 00:48
-
-
Save darkmavis1980/a9c4fa3988715d6200b008b49186c69e to your computer and use it in GitHub Desktop.
Mongodb: Show most recent events by a sub document
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('competitions').aggregate([ | |
{ | |
$unwind: '$matches' | |
}, | |
{ | |
$sort: { 'matches.date': -1 } | |
}, | |
{ | |
$limit: 3 | |
} | |
]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment