You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My issue surrounds the fact that record.save does not check if the new record being saved is already in the database.
The scenario for this is when I am saving a new record without an id, and some other process comes along and creates the record, when the server returns the response, the new record is saved along with the duplicate.
varrecord=this.store.createRecord('user');// Save takes long timerecord.save(user=>console.log(this.store.peekAll('user').mapBy('id'))/* ['userId', 'userId'] */);// while save is being performed and no response yetthis.store.createRecord('user',{id: 'userId'});
This is a bit of a confusing situation, but we have web sockets that also manage our store and we are getting a new record event before the server returns with the response. My understanding is that when we get the web socket event, since there is no record with that id saved yet, it goes ahead and creates the new record. Then when the server returns the response, it never checks the store again to see if that id exists. Thus creating two records in the store with the same id.
Let me know if there are questions.
The text was updated successfully, but these errors were encountered:
@trevorrjohn Yes, unfortunately this has been a known limitation of Ember Data for some time. I'm happy to report that there's an RFC with a proposal to this problem over at emberjs/rfcs#173. Feel free to have a look and leave any feedback over there. I'm closing this issue as a dupe of #1829 where this has been tracked previously.
My issue surrounds the fact that
record.save
does not check if the new record being saved is already in the database.The scenario for this is when I am saving a new record without an id, and some other process comes along and creates the record, when the server returns the response, the new record is saved along with the duplicate.
This is a bit of a confusing situation, but we have web sockets that also manage our store and we are getting a new record event before the server returns with the response. My understanding is that when we get the web socket event, since there is no record with that id saved yet, it goes ahead and creates the new record. Then when the server returns the response, it never checks the store again to see if that id exists. Thus creating two records in the store with the same id.
Let me know if there are questions.
The text was updated successfully, but these errors were encountered: