Можете да използвате $filter
оператор в aggregate
функционира като
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" ] }
}
}
} }
)