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