Answers for "mongodb count array with status matching"

3

mongo count elements in array

> db.mycollection.insert({'foo':[1,2,3,4]})
> db.mycollection.insert({'foo':[5,6,7]})

> db.mycollection.aggregate([{$project: { count: { $size:"$foo" }}}])
{ "_id" : ObjectId("5314b5c360477752b449eedf"), "count" : 4 }
{ "_id" : ObjectId("5314b5c860477752b449eee0"), "count" : 3 }
Posted by: Guest on December-09-2020
3

mongo count elements in array

{ $size: <expression> }
Posted by: Guest on December-09-2020

Code answers related to "mongodb count array with status matching"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language