mercredi 1 mai 2019

Self reference when storing new object

We have a Ruby on Rails backend server and an EmberJS frontend.

We create a new object in Ember that is part of a tree structure (having a parent, children, etc.). We would like to return all the objects in the tree structure as part of the reply from the backend server; eg. when we create a new object we will return self + ancestors. This is where the problem arises. The reply from the server returns an ID for the new object and the same ID is referenced in the self + ancestors data. This results in Ember/Ember data rejecting the data since the ID is already referenced in the data store; eg:

Error: Assertion Failed: 'node' was saved to the server, but the response returned the new id '9f06c18e-0507-41d2-a8af-c330fa896bac', which has already been used with another record.

Is there any way to setup the model so the above is possible? Eg. Ember/Ember data won't reject the new object due to it already being referenced in the reply?




Aucun commentaire:

Enregistrer un commentaire