Painting Blue Code
Simple, self-explanatory code snippets.
2017-02-01
MongoDB - How to count the number of sub-documents in a given field
db.
collection
.aggregate(
{
$unwind
: '
$
field.with.subojects.here
'}
, {
$group
: {
_id: '
$
_id
'
, _count:{
$sum
:
NumberInt
(
1
) }
}}
);
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment