MartinElvar
MartinElvar

Reputation: 5804

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.

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()

But with no luck, what would be the correct way to do this?

Upvotes: 0

Views: 195

Answers (1)

notXX
notXX

Reputation: 594

no way. in standard way, you could filter collection by map.$ref/map.$id/map.$db, where map.$id query is quite useful. 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.

Upvotes: 1

Related Questions