mongoDB bulk insert data

var requests = [];
cursor.forEach(document => { var emailArray4DO = []; var emailArray4EP = [];
var ioJsonArray = document.IndividualsOwnersPara; for (var i1 in ioJsonArray) { var array = ioJsonArray[i1].split("|"); if (emailArray4DO.length < 5) { emailArray4DO.push(array[array.length - 1]); } }
var epJsonArray = document.EngagementPartnerPara; for (var i2 in epJsonArray) { var array = epJsonArray[i2].split("|"); if (emailArray4EP.length < 1) { emailArray4EP.push(array[array.length - 1]); } }
requests.push({ updateOne: { filter: { _id: document._id }, update: { $set: { Email4DO: emailArray4DO, Email4EP: emailArray4EP } } } }); if (requests.length === 500) { db.CitationSource1.bulkWrite(requests); requests = []; } });
if (requests.length > 0) { db.CitationSource1.bulkWrite(requests); }
上一篇:elasticsearch使用python创建或更新文档


下一篇:mysql – 使用标题从CSV文件创建表