So Ember Data Model has a deleteRecord()
that performs a destroyRecord()
without submitting it to the backend.
How do I do save()
without submitting it to the backend?
The reason I need it is that I'm using a custom service to batch-save multiple records of different types (models) in one request. I'm successfully sending the requests, and records are persisted on the backend.
But as the request does not go through the Ember Data pipeline, the response from server will be discarded unless I handle it manually.
Basically, I have this in a service:
// Accepts an array of records of mixed types,
// both existing and new
batchSave (records) {
this
.customAjax(records) // The records are persisted
.then(payload => { // Response from the backend with updated records
store.pushPayload(payload); // Now all records have been updated with their current state
// Now all the records are in their current state.
// But they are still dirty!
// How do I mark them clean and saved
});
I've seen this but it seems to discard dirty attributes, while I want dirty attributes to become clean.
I've also tried store.didSaveRecord()
but after it records are still dirty.