Du behöver inte $unwind
alls. Enkel $match
i pipeline räcker:
pipeline = [
{
"$match" : {
"$or" : [
{
"goes.fridays.fr" : 700
},
{
"goes.special" : {
"$elemMatch" : {
"date" : "2010-01-01",
"fr" : 1000
}
}
}
]
}
}
]
db.students.aggregate(pipeline)
Det kan göras enkelt även utan aggregeringsramverk.
query = {
"$or" : [
{
"goes.fridays.fr" : 700
},
{
"goes.special" : {
"$elemMatch" : {
"date" : "2010-01-01",
"fr" : 1000
}
}
}
]
}
db.students.find(query)