Filter on linked datas. #275

armetiz opened this Issue Mar 13, 2012 · 3 comments


None yet
4 participants

armetiz commented Mar 13, 2012

Hi there,
I think that Doctrine MongoDB Mapper is an great project !
But, I have a question about Referenced Collection.

Documentation says that we can load referenced collection and doctrine links X collection between each other.
Thanks to this feature we can work with referenced objects.

Here an example with prime.

$qb = $dm->createQueryBuilder('User')
$query = $qb->getQuery();

Right now,
I have not find how to "filter" or "query" related datas.
Simple example, If some account aren't enabled, how can I remove them from result.

Here an example of what I need :

$qb = $dm->createQueryBuilder('User')
$query = $qb->getQuery();

The problem is, that it's not working because Doctrine considere that account.enabled is a sub-document of user and not a referenced collection.

Be able to filter reference could be a really awesome feature for Doctrine MongoDB Mapper. Don't you think ?

To be able to get this feature, I think Doctrine MongoDB have to introduce a new function on Query : "join" or something like that to be able to work on the sub-query made be Doctrine.

I have understand that Doctrine make primary request, and then do X sub-requests for X referenced collections.
The only thing to do is to be able to work with the sub-requests.

If we're able to work with the sub-request as we're work with Query API, we can add many thing like "equals", or "sort" and "limit" to sub-request. It will be really really awesome !

What do you think about it ?


jwage commented Mar 13, 2012

I think it would be great. We need to introduce a new concept though so that changes to those partial references are not managed or persisted. If you retrieve back only a subset of a collection and then modify it, the UoW must not try to persist it.

kevou84 commented Dec 23, 2012

+1 :)

Although u could use a Closure, no ?

103: * $qb->field('accounts')->prime(function(DocumentManager $dm) {
104: * // do something that will prime all the associated enabled accounts in one query
105: * });

kevou84 commented Jan 4, 2013

ah, I commented it and just created kind of the same issue today... Sorry :-/
So I guess this is a +2 now ^^

malarzm added the idea label Aug 19, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment