doctrine/mongodb-odm — Issue #264: Query Builder doesn't seem to support "mapped" queries for referenced documents
Author: madhatter42
Created: 2012-03-02 01:07:38+00:00
State: open

In order to retrieve a document with the following structure:

{
"_id" : ObjectId("4f3d6332e9f0233859000000"),
"budget" : 32323,
"buyerCompany" : {
"$ref" : "companies",
"$id" : ObjectId("4f397c91e9f0234026000001")
},
"campaignEnd" : ISODate("2012-03-22T00:00:00Z"),
"campaignStart" : ISODate("2012-03-03T00:00:00Z"),
"created" : ISODate("2012-02-16T20:12:34Z"),
"lastActivity" : ISODate("2012-02-29T20:06:39Z")
}

I'm trying to run a simple query using a $qb->field()->equals() by passing in "buyerCompany" as the field, and array('id' => new \MongoId('4f397c91e9f0234026000001')) into the equals method. But this returns 0 results. However, it seems like the Document Manager's findBy() method supports such queries... with the QB, I'm having to do something like:

$qb->field('buyerCompany.id')->equals(new \MongoId('4f397c91e9f0234026000001'))

Using the dot operator in this way makes this query very Mongo specific.

Any plans to support queries that use the syntax with the array passed in to the equals method (would abstract Mongo away)?