Skip to content

Instantly share code, notes, and snippets.

@Deeptiman
Created November 7, 2021 17:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Deeptiman/847d152f5c00ed09f27e74922dd3c05e to your computer and use it in GitHub Desktop.
Save Deeptiman/847d152f5c00ed09f27e74922dd3c05e to your computer and use it in GitHub Desktop.
db.movies.aggregate(
// Pipeline
[
// Stage 1
{
$match: {
// conditional query
"imdb.rating": {
$lt: 7.5
}
}
},
// Stage 2
{
$group: {
_id: "total_vote",
vote_count: {
$sum: "$imdb.votes"
}
}
},
]
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment