0
我使用express和mongodb npm模塊將數據插入到具有超過1300個收集項目的集合中。我從一個也有1300多個對象的json文件中提取數據。使用下面的代碼,一切都會被正確插入,直到我在mongodb集合中達到100個項目。有沒有辦法解決這個問題,而不會把事情分解成多個集合?如何在mongodb中迭代超過100個項目
我使用的節點下面的代碼:
MongoClient.connect(url, function(err, db) {
db.collection('players').find().forEach(function(myDoc) {
for(var i = 0; i < jsonfile.length; i++) {
if (myDoc.player_ID == jsonfile[i].playerID && myDoc.stint_ID == 1) {
db.collection('players').updateOne(
{ 'player_ID' : jsonfile[i].playerID},
{ $set: {
'strikeOut' : jsonfile[i].SO }
}, function(err, result) {
console.log(err);
db.close();
}
);
} else {
return;
}
}
});
});