doctrine / mongodb-odm

The Official PHP MongoDB ORM/ODM
https://www.doctrine-project.org/projects/doctrine-mongodb-odm/en/latest/
MIT License
1.09k stars 504 forks source link

Using references on embedded document field #1837

Open MatTheCat opened 6 years ago

MatTheCat commented 6 years ago
Q A
New Feature yes
RFC no
BC Break no

The query builder should allow queries like

->field('memberships.organization')->references($organization)

Currently I'm forced to know how the reference is stored and then write

->field('memberships.organization')->equals(new \MongoId($organization->getMongoId()))

This is because Doctrine\ODM\MongoDB\Query\Expr::getReferenceMapping only checks field mapping.

malarzm commented 6 years ago

I was pretty sure we had a similar request in the past but as I can't find I'm gonna keep this open. Scheduling for 2.x, but if @MatTheCat you'd like to tackle this yourself it might find a way into 1.3 :)

MatTheCat commented 6 years ago

I did a quick search but couldn't find anything. As I have a workaround and little time I don't think I'll be able to help :confused:

alcaeus commented 6 years ago

I was pretty sure we had a similar request in the past but as I can't find I'm gonna keep this open.

You were thinking of #1723, which dealt with a similar issue but without the references call: https://github.com/doctrine/mongodb-odm/issues/1723#issuecomment-356531034

malarzm commented 6 years ago

Thanks @alcaeus :older_man: