$elemMatch 返回误报
$elemMatch returning false positive
我的查询:
{ 'objects.item.opts1.opts2': { '$elemMatch': [ { name: 'false' } ] } }
returns: 数组 opts2 中包含任何内容的任何项目,即使我将 'name' 更改为某个不存在的字段,结果也会永远一样
猫鼬模式:
var MySchema = new Schema({
objects: {
item: {
opts1: [{
opts2: [{
name: { type: String },
}]
}],
},
});
在 $elemMatch 中使用不带数组的以下内容....
{ 'objects.item.opts1.opts2': { '$elemMatch': { name: 'false' } } }
我的查询:
{ 'objects.item.opts1.opts2': { '$elemMatch': [ { name: 'false' } ] } }
returns: 数组 opts2 中包含任何内容的任何项目,即使我将 'name' 更改为某个不存在的字段,结果也会永远一样
猫鼬模式:
var MySchema = new Schema({
objects: {
item: {
opts1: [{
opts2: [{
name: { type: String },
}]
}],
},
});
在 $elemMatch 中使用不带数组的以下内容....
{ 'objects.item.opts1.opts2': { '$elemMatch': { name: 'false' } } }