Ember-Data - Delete Models?

Hi there,

First of all, i am using Ember RC6 and Ember-Data 0.13 wit the RESTAdapter.

I am currently trying to delete Models as so:

    var store = this.get('store');
    App.CircleContact.find({
        circle_id: this.controllerFor('circle').get('model').get('id'),
        contact_id: this.get('model').get('id')
    }).then(function(model) {
        model.deleteRecord();
        store.commit();
    });

Besides controllerFor is deprecated; what for gods sake am i doing wrong? I was wondering, why i couln’t find anything with google about how to delete models. Is this a feature not implemented yet or am i just to stupid to find the right way?

Thanks for help, happy coding!

try

model.get(“transaction”).commit();

instead of

store.commit();

thanks for reply.

Sorry, i missed that. The first problem is, that model.deleteRecord() not exists and the code never reaches the commitment.

May be is not a bad idea having a function like this…

Using a promise

How exactly does that work? Where do i have to add the promising function?

I solved the problem by duing the following:

App.CircleContact.find({
        circle_id: this.controllerFor('circle').get('model').get('id'),
        contact_id: this.get('model').get('id')
    }).then(function(content) {
        content.get('content').forEach(function (model) {
            model.record.deleteRecord();
            model.record.get('transaction').commit();
        });
    });

Not nice, not beautiful. Any better suggestions?

This topic was automatically closed after 7 days. New replies are no longer allowed.