问题
I know how to delete multiple models with one line of code:
models.invoke('destroyRecord')
But this results in x calls voor x items. Is there a way to say in Ember Remove all models with one call, where the ids are submitted as request data
?
Of course I can do it by writing my own ajax request
models.invoke('deleteRecord');
Ember.$.ajax({
url: ...,
type: 'DELETE',
data: JSON.stringify( models.map(function(model) { return parseInt(model.get('id')); }) ),
contentType: 'application/json'
}).then(function() {
...
},function(reason) {
...
});
but i wonder if something like this is already in the core.
回答1:
Ember-Data doesn't support deleting multiple records at once out of the box. (That is to say, the adapters and store don't really have built-in methods to do so.) To do it it one AJAX call, you'll have to make the call yourself (like you have).
来源:https://stackoverflow.com/questions/25113960/ember-remove-models-in-one-request