我试图查询多个文档
basename
和
entries
,同时
一个数组包含一个名为
crc
{
"basename": "2020bb",
"entries": [
{
"name": "030-c1.bin",
"extension": "bin",
"basename": "030-c1",
"crc": "4f5e19bd",
"size": 1048576
},
{
"name": "030-c2.bin",
"extension": "bin",
"basename": "030-c2",
"crc": "d6314bf0",
"size": 1048576
},
{
"name": "030-c3.bin",
"extension": "bin",
"basename": "030-c3",
"crc": "47fddfee",
"size": 1048576
}
]
},
{
"basename": "mutnat",
"entries": [
{
"name": "sp-s2.sp1",
"extension": "sp1",
"basename": "sp-s2",
"crc": "9036d879",
"size": 1048576
},
{
"name": "sp-s3.sp1",
"extension": "sp1",
"basename": "sp-s3",
"crc": "c7f2fa45",
"size": 1048576
},
{
"name": "sp-4.sp1",
"extension": "sp1",
"basename": "sp-s4",
"crc": "e72943de",
"size": 1048576
}
]
}
基名
s和
s和我正在尝试找到许多包含正确对的项目。为此,我使用
$in
,
$all
$elemMatch
{
"basename": {
"$in": [
"2020bb",
"mutnat"
]
},
"entries": {
"$in": [
{
"$all": [
{ "$elemMatch": { "crc": "4f5e19bd" } },
{ "$elemMatch": { "crc": "d6314bf0" } },
{ "$elemMatch": { "crc": "47fddfee" } }
]
},
{
"$all": [
{ "$elemMatch": { "crc": "9036d879" } },
{ "$elemMatch": { "crc": "c7f2fa45" } },
{ "$elemMatch": { "crc": "e72943de" } }
]
}
]
}
}
当心
只是为了这个例子的可靠性
s、 实际上,这些数组中有多个项。
MongoError: cannot nest $ under $in
编辑:澄清我的数据和查询