Add static deleteById
This commit is contained in:
parent
588b328e62
commit
b7f7f71b15
25
lib/dao.js
25
lib/dao.js
|
@ -446,6 +446,31 @@ DataAccessObject.destroyAll = function destroyAll(cb) {
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destroy all records
|
||||||
|
* @param {Function} cb - callback called with (err)
|
||||||
|
*/
|
||||||
|
DataAccessObject.deleteById =
|
||||||
|
DataAccessObject.destroyById = function deleteById(id, cb) {
|
||||||
|
if (stillConnecting(this.schema, this, arguments)) return;
|
||||||
|
|
||||||
|
this.schema.adapter.destroy(this.modelName, function (err) {
|
||||||
|
if ('function' === typeof cb) {
|
||||||
|
cb(err);
|
||||||
|
}
|
||||||
|
}.bind(this));
|
||||||
|
};
|
||||||
|
|
||||||
|
// deleteById ~ remoting attributes
|
||||||
|
DataAccessObject.deleteById.accepts = [
|
||||||
|
{arg: 'id', type: 'any'}
|
||||||
|
];
|
||||||
|
DataAccessObject.deleteById.shared = true;
|
||||||
|
DataAccessObject.deleteById.http = [
|
||||||
|
{verb: 'del', path: '/:id'}
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return count of matched records
|
* Return count of matched records
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue