在Mongoose中,insertMany与collection.insert有什么不同?

我search了一下,find了使用Mongoose向MongoDB插入大量文档的正确解决scheme。

我目前的解决scheme如下所示:

MongoClient.saveData = function(RecordModel, data, priority, SCHID, callback){ var dataParsed = parseDataToFitSchema(data, priority, SCHID); console.log("Model created. Inserting in batches."); RecordModel.insertMany(dataParsed) .then(function(mongooseDocuments) { console.log("Insertion was successful."); }) .catch(function(err) { callback("Error while inserting data to DB: "+err); return; }) .done(function() { callback(null); return; }); } 

但在我看来,还有其他提供的解决scheme。 像这样: http : //www.unknownerror.org/opensource/Automattic/mongoose/q/stackoverflow/16726330/mongoose-mongodb-batch-insert

使用collection.insert 。 这与Model.insertMany什么不同?

我的上一个问题同样适用于更新: 使用Mongoose更新MongoDB中的许多logging的正确方法是什么?

问我如何使用由_id定义的Mongoose更新大块数据。 答案build议使用collection.bulkWrite而我在印象之下Model.insertMany也可以做到这一点。