$size
を使用できます
配列の長さを見つけるための集計演算子。
company.aggregate([
{ "$lookup": {
"from": "userFocus",
"localField": "_id",
"foreignField": "value",
"as": "focusUsers"
}},
{ "$project": {
"name": 1,
"focusUsers": 1,
"focusCount": { "$size": "$focusUsers" }
}}
])