简体   繁体   English

按引用的嵌入式文档过滤

[英]Filter by referenced embedded document

I need to filter by a property in the the embeded document Map, the problem is that it is referenced. 我需要按嵌入文档Map中的属性进行过滤,问题是它已被引用。

Game -> Structure. 游戏->结构。

"_id" : ObjectId( "51051e7d8ead0ebd4e000000" ),
  "active" : true,
  "created" : 1359289981,
  "difficulty" : 0,
  "map" : { "$ref" : "Map",
    "$id" : ObjectId( "5103c0228ead0e3764000000" ),
    "$db" : "fantasytd" },
  "mode" : "coop",

With a non referenced embeded document, this would be sufficient 对于未引用的嵌入文档,这将足够

$q->field('map.playerLimit')->equals($playerLimit);

i tried using the 我尝试使用

$q->field('map')->prime() $ q-> field('map')-> prime()

But with no luck, what would be the correct way to do this? 但是,没有运气,这样做的正确方法是什么?

no way. 没门。 in standard way, you could filter collection by map.$ref/map.$id/map.$db, where map.$id query is quite useful. 以标准方式,您可以按map。$ ref / map。$ id / map。$ db过滤集合,其中map。$ id查询非常有用。 filtering by other properties of the referenced document is totally another thing. 通过引用文档的其他属性进行过滤完全是另一回事。 maybe you could save the intersted property in DBRef and query it as normal, which you should not, and it would not work in some future version. 也许您可以将intersted属性保存在DBRef中,然后像平常一样查询它,而不应该这样做,并且在将来的某些版本中将不起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM