[MODM-105] inversedBy as ORM Created: 07/Jan/11  Updated: 04/Mar/11  Resolved: 04/Mar/11

Status: Resolved
Project: Doctrine MongoDB ODM
Component/s: None
Affects Version/s: 1.0.0BETA2
Fix Version/s: 1.0.0BETA3

Type: New Feature Priority: Major
Reporter: Henrik Bjornskov Assignee: Jonathan H. Wage
Resolution: Fixed Votes: 0
Labels: None


 Description   

A way to specify "inversedBy" when mapping referenceOne and referenceMany as the ORM have it.



 Comments   
Comment by Jonathan H. Wage [ 11/Feb/11 ]

hmm. I am not sure if having inversedBy makes sense for the mongodb odm based on how references currently work. What would it be used for? relationships in the odm don't work like they do in the orm. We don't use foreign keys to get a reference, we store a reference document on the document that is doing the referencing.

Comment by Jonathan H. Wage [ 19/Feb/11 ]

Thinking about this more:

/** @Document */
class Product
{
    /** @ReferenceOne(targetDocument="Seller") */
    private $seller;
}

/** @Document */
class Seller
{
    /** @ReferenceMany(targetDocument="Product", inversedBy="seller") */
    private $products;
}

Now the $products association will be loaded by running a query like this:

db.products.find({ 'seller.$id' : seller.id })

Is this what you mean?

Comment by Henrik Bjornskov [ 20/Feb/11 ]

Sorry not getting back to you about this sooner. But that is exactly what i mean can also be done for reference one i think

Comment by Jonathan H. Wage [ 20/Feb/11 ]

Can you help me think through the other scenariors where it can be used? and how mappedBy would be used. We just need to be sure to think through all the semantics and define it all before I start trying to implement it.

Comment by Jonathan H. Wage [ 20/Feb/11 ]

I implemented this here https://github.com/doctrine/mongodb-odm/commit/d1bffbd6bb7b7b690e25f1314f1bf6b69f1e41a6

Can you check it out and give some feedback?

Comment by Henrik Bjornskov [ 21/Feb/11 ]

Yes i will play around with it later today

Generated at Mon Jul 28 04:27:51 UTC 2014 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.