Add static deleteById

This commit is contained in:
Raymond Feng 2013-07-22 09:42:09 -07:00
parent 588b328e62
commit b7f7f71b15
1 changed files with 25 additions and 0 deletions

View File

@ -446,6 +446,31 @@ DataAccessObject.destroyAll = function destroyAll(cb) {
}.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
*