Created
July 18, 2024 17:57
-
-
Save mrlynn/505b2f9c92a9d8ea8a71eba1019bbaef to your computer and use it in GitHub Desktop.
Example MongoDB Aggregation
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
db.reviews.aggregate([ | |
{ | |
$group: { | |
_id: "$bookId", | |
averageRating: { | |
$avg: "$rating" | |
} | |
} | |
}, | |
{ | |
$match: { | |
averageRating: 5 | |
} | |
} | |
]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment