S aggregate :
db.companies.aggregate([
{ $match: { "founded_year":2004 } },
{ $project: { founded_year:1,
moreThanFive: { $gt: [ {$size: "$external_links" }, 5 ] } } },
{ $match: { moreThanFive : true }} ,
])
Budete potřebovat:
1. Zahrnout $project fázi, abyste zjistili počet investic (size pole) a zkontrolujte, zda je větší než 5.
2. a poté proveďte další $match fázi pro filtrování pomocí moreThanFive rovná se true .
Pomocí find :
db.companies.find({'investments.5': {$exists: true}})
Ptáte se, zda pozice číslo 6 v investments pole existuje.