mongodb make query json size greater than 1 code example
Example 1: query document array size greater than 1
// Find all docs that have at least two name array elements.
db.accommodations.find({'name.1': {$exists: true}})
Example 2: mongodb count array size
db.inventory.aggregate([
{
$project: {
item: 1,
numberOfColors: { $cond: { if: { $isArray: "$colors" }, then: { $size: "$colors" }, else: "NA"} }
}
}
] )