jaydata icon indicating copy to clipboard operation
jaydata copied to clipboard

Support for mongoDB embedded relationship is not transparent. It doesn't work with inverse relations

Open lawaks opened this issue 11 years ago • 1 comments

If you define your data model with relationships using the classic inverse property paradigm, then it won't be possible to retrieve the entity using an "include relationship" if mongoDB is used as a provider where nested relationship is used instead of DB reference. For example: 1) Parent: parent Attribute... parentChildren: inverse relation definition

Child: Child Attribute.. childParent: inverser relation definition

  1. In MongoDB, insert parentChildren as a nested relationships. (i.e. db.save({parentAttribute:value, parentChildren:[child1, child2]})

  2. In JayData, this won't work: db.Parent.include('parentChildren').toArray(); The parentChildren array will always be empty.

If nested relations is used in mongoDB, then you cannot mark parentChildren as a navigation property (inverse relation) in JayData model. As a result, your model definition is coupled with your data provider.

lawaks avatar Mar 23 '14 17:03 lawaks

I am not sure if this is the same issue, but I run into problems when I wanted to represent a DMS-like recursive structure of folders using the same parent-child association that you describe. I was not able to use JayData to populate the database with entities; I had to use the MongoDB API to create the documents with the necessary ID and DBRef properties. Exposing the database in an OData service provided by the ODataServer to query its contents worked.

prantlf avatar Sep 13 '14 11:09 prantlf