Quantcast
Channel: Ember.JS - Latest topics
Viewing all articles
Browse latest Browse all 4870

EmbeddedRecordsMixin saving belongsTo

$
0
0

I know there’s some pending issues related to saving embedded relationships but I’m not 100% sure this case falls under the un-implemented changes.

I have a parent model with a belongsTo relationship and there’s two different scenarios I need to handle:

  1. Creating a new record and saving
  2. Updating an existing record and saving

For case 1, I am saving the parent and removing any child records lingering in the store with id == null which works fine.

For case 2, I am saving the parent but the child record is remaining in the dirty state. Is there any similar workarounds for existing records that I can use such as in case 1 where my store is in a clean state after saving? Or is this a case that should be working but somehow being mishandled on my end?

From my understanding, the issues with case 1 is that the client-side record has no id and therefore no explicit way of correlating the embedded record in the save response to the one on the client. For case 2, both client and server already have correlated IDs for the embedded record so I would expect the save response to just overwrite the dirty attributes in the store.

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 4870

Trending Articles