Details

    • Type: New Feature New Feature
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.0.0BETA2
    • Fix Version/s: 1.0.0BETA3
    • Component/s: None
    • Labels:
      None

      Description

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

        Activity

        Hide
        Henrik Bjornskov added a comment -

        Yes i will play around with it later today

        Show
        Henrik Bjornskov added a comment - Yes i will play around with it later today
        Hide
        Jonathan H. Wage added a comment -

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

        Can you check it out and give some feedback?

        Show
        Jonathan H. Wage added a comment - I implemented this here https://github.com/doctrine/mongodb-odm/commit/d1bffbd6bb7b7b690e25f1314f1bf6b69f1e41a6 Can you check it out and give some feedback?
        Hide
        Jonathan H. Wage added a comment -

        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.

        Show
        Jonathan H. Wage added a comment - 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.
        Hide
        Henrik Bjornskov added a comment -

        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

        Show
        Henrik Bjornskov added a comment - 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
        Hide
        Jonathan H. Wage added a comment -

        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?

        Show
        Jonathan H. Wage added a comment - 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?
        Hide
        Jonathan H. Wage added a comment -

        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.

        Show
        Jonathan H. Wage added a comment - 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.

          People

          • Assignee:
            Jonathan H. Wage
            Reporter:
            Henrik Bjornskov
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: