Created
September 7, 2021 16:01
-
-
Save ryanvgates/804b2fc9efd9e422fccbd22bf8855b3c to your computer and use it in GitHub Desktop.
MongoDB Long Running Query
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
use mydb; | |
rs.secondaryOk(); | |
db.Collection.aggregate([ | |
{ | |
$match: { | |
groups: { $exists: true } | |
} | |
}, | |
{ | |
$group: { | |
_id: { | |
CustomerId: "$CustomerId", | |
}, | |
groups: { $sum: { $size: "$Groups" } } | |
} | |
}, | |
{ | |
$match: { | |
"countGroups": { $gt: 0 } | |
} | |
} | |
]).toArray(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment