Du kan bruge $size
aggregeringsoperator for at finde længden af et array.
company.aggregate([
{ "$lookup": {
"from": "userFocus",
"localField": "_id",
"foreignField": "value",
"as": "focusUsers"
}},
{ "$project": {
"name": 1,
"focusUsers": 1,
"focusCount": { "$size": "$focusUsers" }
}}
])