so i have a bunch of simple documents like
{
\"foos\": [
ObjectId(\"5105862f2b5e30877c685c58\"),
ObjectId(\"5105862f2b5e30877c685c57\"),
Obje
I know this is an old question but you can bypass project altogether if you want, so how about this?
db.profil.aggregate([
{
"$match":{ "typ": "Organisation" }
},
{
"$group":
{
"_id": null,
"count":
{
"$sum": { "$size": "$foos" }
}
}
}])
The output remains the same and it seems it's (slightly) faster.