Skip to content

Commit

Permalink
Merge pull request #8004 from Fonger/fix/query-delete-options
Browse files Browse the repository at this point in the history
fix(query): add missing options for deleteOne and deleteMany in Query
  • Loading branch information
vkarpov15 committed Jul 22, 2019
2 parents 6d6c5bb + 962aaee commit 8911102
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions lib/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -2603,17 +2603,24 @@ Query.prototype._remove = wrapThunk(function(callback) {
* res.deletedCount;
*
* @param {Object|Query} [filter] mongodb selector
* @param {Object} [options] optional see [`Query.prototype.setOptions()`](http://mongoosejs.com/docs/api.html#query_Query-setOptions)
* @param {Function} [callback] optional params are (error, mongooseDeleteResult)
* @return {Query} this
* @see deleteWriteOpResult http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#~deleteWriteOpResult
* @see MongoDB Driver deleteOne http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#deleteOne
* @api public
*/

Query.prototype.deleteOne = function(filter, callback) {
Query.prototype.deleteOne = function(filter, options, callback) {
if (typeof filter === 'function') {
callback = filter;
filter = null;
options = null;
} else if (typeof options === 'function') {
callback = options;
options = null;
} else {
this.setOptions(options);
}

filter = utils.toObject(filter);
Expand Down Expand Up @@ -2679,17 +2686,24 @@ Query.prototype._deleteOne = wrapThunk(function(callback) {
* res.deletedCount;
*
* @param {Object|Query} [filter] mongodb selector
* @param {Object} [options] optional see [`Query.prototype.setOptions()`](http://mongoosejs.com/docs/api.html#query_Query-setOptions)
* @param {Function} [callback] optional params are (error, mongooseDeleteResult)
* @return {Query} this
* @see deleteWriteOpResult http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#~deleteWriteOpResult
* @see MongoDB Driver deleteMany http://mongodb.github.io/node-mongodb-native/3.1/api/Collection.html#deleteMany
* @api public
*/

Query.prototype.deleteMany = function(filter, callback) {
Query.prototype.deleteMany = function(filter, options, callback) {
if (typeof filter === 'function') {
callback = filter;
filter = null;
options = null;
} else if (typeof options === 'function') {
callback = options;
options = null;
} else {
this.setOptions(options);
}

filter = utils.toObject(filter);
Expand Down

0 comments on commit 8911102

Please sign in to comment.