Add deleteRecord API to store to support deleting a tag

This commit is contained in:
Robin Ward 2015-03-05 17:13:32 -05:00
parent e63a24a08a
commit 34294ca748
2 changed files with 17 additions and 0 deletions

View File

@ -15,6 +15,11 @@ const RestModel = Ember.Object.extend({
self.setProperties(attrs);
return result;
});
},
destroyRecord() {
const type = this.get('__type');
return this.store.destroyRecord(type, this.get('id'));
}
});
@ -60,6 +65,13 @@ export default Ember.Object.extend({
});
},
destroyRecord(type, id) {
return Discourse.ajax(this.pathFor(type, id), { method: 'DELETE' }).then(function(result) {
delete _identityMap[type][id];
return result;
});
},
createRecord(type, attrs) {
return this._hydrate(type, attrs);
},

View File

@ -12,5 +12,10 @@ export default Ember.Object.extend({
createRecord(type, attrs) {
const adapter = this.container.lookup('adapter:' + type) || this.container.lookup('adapter:rest');
return adapter.createRecord(type, attrs);
},
destroyRecord(type, id) {
const adapter = this.container.lookup('adapter:' + type) || this.container.lookup('adapter:rest');
return adapter.destroyRecord(type, id);
}
});