Skip to content

Commit

Permalink
test: fix tests re: Automattic/mongoose#6880
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Aug 22, 2018
1 parent f6296ab commit 8aa1b4a
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions lib/mquery.js
Expand Up @@ -2806,19 +2806,19 @@ Query.prototype.findOneAndRemove = Query.prototype.findOneAndDelete = function(c
Query.prototype._findAndModify = function(type, callback) {
assert.equal('function', typeof callback);

var opts = this._optionsForExec(),
fields,
doc;
var options = this._optionsForExec();
var fields;
var doc;

if ('remove' == type) {
opts.remove = true;
options.remove = true;
} else {
if (!('new' in opts)) opts.new = true;
if (!('upsert' in opts)) opts.upsert = false;
if (!('new' in options)) options.new = true;
if (!('upsert' in options)) options.upsert = false;

doc = this._updateForExec();
if (!doc) {
if (opts.upsert) {
if (options.upsert) {
// still need to do the upsert to empty doc
doc = { $set: {} };
} else {
Expand All @@ -2838,15 +2838,14 @@ Query.prototype._findAndModify = function(type, callback) {

var conds = this._conditions;

debug('findAndModify', this._collection.collectionName, conds, doc, opts);
debug('findAndModify', this._collection.collectionName, conds, doc, options);
callback = this._wrapCallback('findAndModify', callback, {
conditions: conds,
doc: doc,
options: opts
options: options
});

this._collection
.findAndModify(conds, doc, opts, utils.tick(callback));
this._collection.findAndModify(conds, doc, options, utils.tick(callback));

return this;
};
Expand Down

0 comments on commit 8aa1b4a

Please sign in to comment.