Created
May 5, 2015 18:25
-
-
Save andypham/799291b7f691a92af9d5 to your computer and use it in GitHub Desktop.
sails mongo topology was destroyed exception - sails-mongo/lib/collection.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Collection.prototype.insert = function insert(values, cb) { | |
var self = this; | |
// Normalize values to an array | |
if(!Array.isArray(values)) values = [values]; | |
// Build a Document and add the values to a new array | |
var docs = values.map(function(value) { | |
return new Document(value, self.schema).values; | |
}); | |
this.connection.db.collection(this.identity).insert(docs, function(err, results) { | |
if(err) return cb(err); | |
setTimeout(function() { | |
cb(null, utils.rewriteIds(results.ops, self.schema)); | |
}, 10); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment