diff --git a/lib/collection.js b/lib/collection.js index a38801b33b..d4f13e2757 100644 --- a/lib/collection.js +++ b/lib/collection.js @@ -1014,8 +1014,8 @@ var updateDocuments = function(self, selector, document, options, callback) { // Execute the operation var op = { q: selector, u: document }; - op.upsert = typeof options.upsert === 'boolean' ? options.upsert : false; - op.multi = typeof options.multi === 'boolean' ? options.multi : false; + op.upsert = options.upsert !== void 0 ? !!options.upsert : false; + op.multi = options.multi !== void 0 ? !!options.multi : false; if (finalOptions.arrayFilters) { op.arrayFilters = finalOptions.arrayFilters; @@ -2124,9 +2124,8 @@ var findOneAndReplace = function(self, filter, replacement, options, callback) { var finalOptions = shallowClone(options); finalOptions['fields'] = options.projection; finalOptions['update'] = true; - finalOptions['new'] = - typeof options.returnOriginal === 'boolean' ? !options.returnOriginal : false; - finalOptions['upsert'] = typeof options.upsert === 'boolean' ? options.upsert : false; + finalOptions['new'] = options.returnOriginal !== void 0 ? !options.returnOriginal : false; + finalOptions['upsert'] = options.upsert !== void 0 ? !!options.upsert : false; // Execute findAndModify self.findAndModify(filter, options.sort, replacement, finalOptions, callback);