Z aggregate :
db.companies.aggregate([
{ $match: { "founded_year":2004 } },
{ $project: { founded_year:1,
moreThanFive: { $gt: [ {$size: "$external_links" }, 5 ] } } },
{ $match: { moreThanFive : true }} ,
])
Musisz:
1. Dołącz $project etap, aby znaleźć numer inwestycji (size tablicy) i sprawdź, czy jest większa niż 5.
2. a następnie wykonaj kolejne $match etap do filtrowania tych za pomocą moreThanFive równa się true .
Z find :
db.companies.find({'investments.5': {$exists: true}})
Pytasz, czy pozycja numer 6 w investments tablica istnieje.