Comparing version 2.13.0 to 2.13.1
@@ -515,6 +515,13 @@ var _ = require('lodash'), | ||
if(queryOptions.upsert) | ||
this.collection.findAndModify({ _id: prepped._id }, { _id: 1 }, prepped, queryOptions, (function(err, inserted) { | ||
async.parallel(_.map(prepped, function(doc) { | ||
return (function(done) { | ||
this.collection.findAndModify({ _id: doc._id }, { _id: 1 }, doc, queryOptions, function(err, result) { | ||
if(err) return done(err); | ||
return done(null, result); | ||
}); | ||
}).bind(this); | ||
}, this), (function(err, inserted) { | ||
if (err) return end(err); | ||
if(callback) | ||
return this.onRetrieved(null, inserted[0], end, null, { wrap: options.wrap, cache: options.cache }); | ||
return this.onRetrieved(null, inserted, end, null, { wrap: options.wrap, cache: options.cache }); | ||
return end(); | ||
@@ -521,0 +528,0 @@ }).bind(this)); |
{ | ||
"name": "iridium", | ||
"version": "2.13.0", | ||
"version": "2.13.1", | ||
"author": "Benjamin Pannell <admin@sierrasoftworks.com>", | ||
@@ -5,0 +5,0 @@ "description": "A custom lightweight ORM for MongoDB designed for power-users", |
@@ -99,2 +99,17 @@ var config = require('./config.js'); | ||
}); | ||
it('should support upsert operations with multiple documents', function(done) { | ||
model.create([{ | ||
name: 'Demo1', | ||
upserted: true | ||
},{ | ||
name: 'Demo5', | ||
upserted: true | ||
}], { upsert: true }, function(err, updated) { | ||
should.not.exist(err); | ||
should.exist(updated); | ||
updated.length.should.equal(2); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
@@ -101,0 +116,0 @@ }); |
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
161954
3005