Comparing version 7.0.0 to 7.0.1
@@ -318,3 +318,3 @@ "use strict"; | ||
} | ||
options = options || {}; | ||
const opts = options || {}; | ||
if (!_.isPlainObject(conditions)) | ||
@@ -324,3 +324,3 @@ conditions = { | ||
}; | ||
_.defaults(options, { | ||
_.defaults(opts, { | ||
w: "majority", | ||
@@ -332,10 +332,16 @@ multi: true | ||
return new Bluebird((resolve, reject) => { | ||
this.collection.updateMany(conditions, changes, options, (err, response) => { | ||
if (opts.multi) | ||
return this.collection.updateMany(conditions, changes, opts, (err, response) => { | ||
if (err) | ||
return reject(err); | ||
// New MongoDB 2.6+ response type | ||
if (response.result && response.result.nModified !== undefined) | ||
return resolve(response.result.nModified); | ||
// Legacy response type | ||
return resolve(response.result.n); | ||
}); | ||
return this.collection.update(conditions, changes, opts, (err, response) => { | ||
if (err) | ||
return reject(err); | ||
// New MongoDB 2.6+ response type | ||
if (response.result && response.result.nModified !== undefined) | ||
return resolve(response.result.nModified); | ||
// Legacy response type | ||
return resolve(response.result.n); | ||
return resolve(1); | ||
}); | ||
@@ -342,0 +348,0 @@ }); |
@@ -666,2 +666,5 @@ "use strict"; | ||
}); | ||
it("should allow multi update to be disabled", () => { | ||
return chai.expect(model.update({ _id: { $exists: true } }, { $inc: { answer: 1 } }, { multi: false })).to.eventually.equal(1); | ||
}); | ||
it("should allow just the ID to be specified", () => { | ||
@@ -672,2 +675,7 @@ return model.get().then(instance => { | ||
}); | ||
it("should allow replacement updates to be conducted", () => { | ||
return model.get().then(instance => { | ||
return chai.expect(model.update(instance._id, instance.document, { multi: false })).to.eventually.equal(1); | ||
}); | ||
}); | ||
it("should allow filtering using a selector", () => { | ||
@@ -674,0 +682,0 @@ return chai.expect(model.update({ answer: 10 }, { $inc: { answer: 1 } })).to.eventually.equal(1); |
{ | ||
"name": "iridium", | ||
"version": "7.0.0", | ||
"version": "7.0.1", | ||
"author": "Benjamin Pannell <admin@sierrasoftworks.com>", | ||
@@ -50,3 +50,3 @@ "description": "A custom lightweight ORM for MongoDB designed for power-users", | ||
"engines": { | ||
"node": ">= 0.10" | ||
"node": ">= 6.0" | ||
}, | ||
@@ -53,0 +53,0 @@ "dependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1
697045
171
7280