Puoi utilizzare $filter
operatore nell'aggregate
funziona come
users = User.objects(school__match={ "name": "Aukamm Elementary School" }).aggregate(
{ "$project": {
"first_name": 1,
"last_name": 1,
"schools": {
"$filter": {
"input": "$schools",
"as": "school",
"cond": { "$eq": [ "$$school.name", "Aukamm Elementary School" ] }
}
}
} }
)