Last active
December 31, 2015 20:29
-
-
Save anscii/8040820 to your computer and use it in GitHub Desktop.
Count mongo subarrays with subarray field matching for all possible _ids
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.tag_ru.aggregate({ $unwind: '$items'}, { $match: { "items.type":"news"}}, { $group: {_id: '$_id', count: {$sum: 1}}}, {$group: {_id:null, cnt:{$sum:"$count"} } } ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment