我有一个循环功能,我正在测试我的一条路线。问题是当我调用它时,它会挂起所有网络调用,直到它完成该功能。我想知道如何在处理节点时不锁定节点。
app.get('/populate', routes.populate);
exports.populate = function(req, res, next){
for(i = 0; i < 100000; i++){
var tmp = new Encounters();
tmp.kareoId = '1234'; //mock.Address.zipCode();
tmp.patient.fullName = 'Vartan Arabyan'; //mock.Name.findName();
tmp.patient.dob = Date.now();
tmp.patient.kareoId = '12312'; //mock.Address.zipCode();
tmp.physician.fullName = "Dr." + 'Vartan Arabyan'; //mock.Name.findName();
tmp.physician.kareoId = '12312'; //mock.Address.zipCode();
tmp.appointmentType = "NCV Upper";
tmp.appointment = Date.now();
tmp.save(function(err){
if (err) throw err;
});
if(i == 99999){
res.send(200, 'Fake Data Loaded');
}
}
};