Querying by nested references values in mongodb / doctrine2 odm

By : Michal
Source: Stackoverflow.com

Hello ive got the following code:

        $primer = function($dm, $className, $fieldName, $ids, $hints) {
        $repository = $dm->getRepository($className);
        $qb = $repository->createQueryBuilder()
        $query = $qb->getQuery();

    $qb = $followRepo
        ->field('target.createdBy.type')->equals('user') // here i dont know how to handle this
        ->sort('created', 'desc')

Is it even possible in mongo to query via target.createdBy.type? target.createdBy is also ref.

By : Michal

Yes, it is possible to query on sub document properties using the dot notation, as per the official documentation. I am pretty sure it wont work with a referencing in 1 step though.

This video can help you solving your question :)
By: admin