我的Mongo数据库中有两个集合,Foo
包含对一个或多个Bar
的引用:
Foo: {
prop1: true,
prop2: true,
bars: [
{
"$ref": "Bar",
"$id": ObjectId("blahblahblah")
}
]
}
Bar: {
testprop: true
}
我想要的是找到所有Foo
个至少有一个Bar
的测试属性设置为true的.我try 过这个命令,但它没有返回任何结果:
db.Foo.find({ "bars.testprop" : { "$in": [ true ] } })
有什么 idea 吗?