我收到了这样的文件:
{
"_id" : ObjectId("54ad5c3b9a703a3c088b4567"),
"hard" : 750,
"coordinates" : {
"x" : 0.2388169910939489,
"y" : 0.7996551291084174
},
"indicator" : 500,
"networkIdList" : {
"networkIdData" : [
{
"networkId" : "abc123",
"type" : "SomeNetwork"
},
{
"networkId" : "123asdf",
"type" : "AnotherNetWork"
},
{
"networkId" : "abc123",
"type" : "OneMoreNetwork"
}
]
}
}
我需要执行一个查询来查找具有" networkId"的文档。 =" abc123" AND"键入" =" SomeNetwork"。
我试过这条指令:
$this->documentManager->createQueryBuilder('Mydocument') ->field('networkIdList.networkIdData.$.networkGamingId')->equals('abc123') ->field('networkIdList.networkIdData.$.type')->equals('')
->getQuery()
->execute());
但是光标没有返回数据。
我也尝试用
->where("function() {return this.networkIdList.networkIdData.$.networkGamingId == 'abc123'}")
但在这种情况下,我收到一条错误,指出Object $没有任何属性。
答案 0 :(得分:1)
我需要执行一个查询来查找具有" networkId"的文档。 =" abc123" AND"键入" =" SomeNetwork"
$qb = $dm->createQueryBuilder('Foo')
->field('networkIdList.networkIdData.networkId')->equals('abc123')
->field('networkIdList.networkIdData.type')->equals('SomeNetwork');