diff options
| author | Sean Fridman <fridman@mail.sfsu.edu> | 2015-04-09 15:59:19 -0400 |
|---|---|---|
| committer | Sean Fridman <fridman@mail.sfsu.edu> | 2015-04-09 15:59:19 -0400 |
| commit | 757f6992aea253b06cc4f65fa0dd7da71cf82135 (patch) | |
| tree | 38d5a3974d57b98d435430f35245949bcf7fab96 /app | |
| parent | d51924d7296af861ee2d9d95b8ded12708679a66 (diff) | |
Implement FSDB.remove
Diffstat (limited to 'app')
| -rw-r--r-- | app/node_modules/okdb/index.js | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/app/node_modules/okdb/index.js b/app/node_modules/okdb/index.js index 79ce1eb..4be646d 100644 --- a/app/node_modules/okdb/index.js +++ b/app/node_modules/okdb/index.js @@ -81,8 +81,15 @@ FSDB.prototype.create = function(collection, data) { return this._resolve(created); }; -FSDB.prototype.remove = function(collection, id, data) { - throw new Error('Not implemented!'); +FSDB.prototype.remove = function(collection, query) { + if (!collection || !query) { + return this._resolve(null, new Error('Bad input')); + } else { + var data = this._db(collection).removeWhere(query); + if (!data) + var error = new Error('Cannot remove nonexistent entry'); + return this._resolve(data, error); + } }; FSDB.prototype.find = function(collection, query) { |
