From c4d8ee7c431b3511bf26da68e952808b51d663c7 Mon Sep 17 00:00:00 2001 From: Sean Fridman Date: Thu, 9 Apr 2015 16:00:21 -0400 Subject: Add resource delete functionality to admin --- app/node_modules/okresource/index.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'app/node_modules/okresource/index.js') diff --git a/app/node_modules/okresource/index.js b/app/node_modules/okresource/index.js index febd1d5..0e8498f 100644 --- a/app/node_modules/okresource/index.js +++ b/app/node_modules/okresource/index.js @@ -91,14 +91,16 @@ OKResource.prototype.create = function(data) { }); }; -OKResource.prototype.destroy = function(data) { - data = data || {}; - var id = data[this.idField]; +OKResource.prototype.destroy = function(id) { + var db = this._db; + var type = this.type; + var query = {}; + query[this.idField] = id; return Q.promise(function(resolve, reject) { if (!id) { - reject(new Error('Data does not contain ID property')); + reject(new Error('No ID given')); } else { - this._db.remove(this.type, data.id, data).then(resolve).fail(reject); + db.remove(type, query).then(resolve).fail(reject); } }); }; -- cgit v1.2.3-70-g09d2