【发布时间】:2015-10-28 20:23:08
【问题描述】:
我有以下 2 个文档,如果任何文档在图像数组中具有 4x4 或 3x3,我需要在其中搜索。
{
"images" : [
{
"4x4" : {
"path" : "4-1.jpg"
},
"2x2" : {
"path" : "2-1.jpg"
}
}
]
}
{
"images" : [
{
"3x3" : {
"path" : "3-1.jpg"
}
}
]
}
我有以下 mongodb 查询。但似乎无法找到一起使用 $or 和 $elemMatch 的方法。
db.getCollection('images').find({
"images" : {
$elemMatch : {
"4x4" : {$exists : true}
}
}
})
【问题讨论】:
标签: mongodb mongodb-query