Skip to content

Commit

Permalink
Simplify remove
Browse files Browse the repository at this point in the history
  • Loading branch information
saintedlama committed Nov 30, 2015
1 parent d079280 commit 67acfa2
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions lib/collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,18 +134,12 @@ Collection.prototype.remove = function (query, options, cb) {
this._getCollection(function (err, collection) {
if (err) return cb(err)

// TODO: Duplicate code - see xtend below
if (options.justOne) {
collection.deleteOne(query, xtend(writeOpts, options), function (err, result) {
if (err) return cb(err)
cb(null, result.result)
})
} else {
collection.deleteMany(query, xtend(writeOpts, options), function (err, result) {
if (err) return cb(err)
cb(null, result.result)
})
}
var deleteOperation = options.justOne?'deleteOne':'deleteMany';

collection[deleteOperation](query, xtend(writeOpts, options), function (err, result) {
if (err) return cb(err)
cb(null, result.result)
})
})
}

Expand Down

0 comments on commit 67acfa2

Please sign in to comment.