Reputation: 304
I currently have a field on a document of the posts collection which is a ReferenceOne to a collection of users. Querying on the shell db.posts.findOne({"usuario_stream.$id": ObjectId("5012d7674dfbad7f4e000084")})
works fine, but using the QueryBuilder it simply doesn't works.
$this->doctrine->createQueryBuilder('Documents\Posts')->field('usuario_stream.$id')->equals(new MongoId('5012d7674dfbad7f4e000084'))->eagerCursor(true)->getQuery()->execute();
on profiler shows { "$query" : { "usuario_stream.$id" : null }, "$orderby" : [ ] }
.
I'm doing anything wrong?
Upvotes: 2
Views: 1773
Reputation: 3839
It should work if you query on usuario_stream.$id using the ID as a string rather than an instance of MongoID:
->field('usuario_stream.$id')->equals('5012d7674dfbad7f4e000084')
Upvotes: 3