Skip to content

Commit

Permalink
doc#remove now passes safe options
Browse files Browse the repository at this point in the history
how has this gone unnoticed?
  • Loading branch information
aheckmann committed Jun 5, 2012
1 parent 214ecbe commit d932343
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions lib/model.js
Expand Up @@ -482,15 +482,22 @@ Model.prototype.remove = function remove (fn) {


var promise = this._removing = new Promise(fn) var promise = this._removing = new Promise(fn)
, where = this._where() , where = this._where()
, self = this; , self = this
, options = {}

if (this.options.safe) {
options.safe = this.options.safe;
}


this.collection.remove(where, tick(function (err) { this.collection.remove(where, options, tick(function (err) {
if (err) { if (err) {
this._removing = null; promise.error(err);
return promise.error(err); promise = self = self._removing = where = options = null;
return;
} }
promise.complete(); promise.complete();
self.emit('remove', self); self.emit('remove', self);
promise = self = where = options = null;
})); }));


return this; return this;
Expand Down

0 comments on commit d932343

Please sign in to comment.