这是我的文档的外观:
nookstore = {
"name": "Nook store",
"categories": ["bookstore"],
"working_hours": [
{"opens": 8*60*60, "closes": 21*60*60 },
{"opens": 8*60*60, "closes": 21*60*60 },
{"opens": 8*60*60, "closes": 21*60*60 },
{"opens": 8*60*60, "closes": 21*60*60 },
{"opens": 8*60*60, "closes": 21*60*60 },
{"opens": 8*60*60, "closes": 21*60*60 },
{"opens": 9*60*60, "closes": 20*60*60 },
]
}
...
kindlestore = {
"name": "Kindle store",
"categories": ["bookstore"],
"working_hours": [
{"opens": 0, "closes": 24*60*60 },
{"opens": 0, "closes": 24*60*60 },
{"opens": 0, "closes": 24*60*60 },
{"opens": 0, "closes": 24*60*60 },
{"opens": 0, "closes": 24*60*60 },
{"opens": 0, "closes": 24*60*60 },
{"opens": 0, "closes": 24*60*60 },
],
}
我正在寻找 24 小时营业的商店,即每个元素的working_hours
营业时间0
和关闭时间24*60*60
(午夜后几秒)的商店。
我尝试使用$all
and $elemMatch
,但如果数组的至少一个元素与给定条件匹配(我不需要),它们在我需要匹配的情况下工作。