var inputStream = fs.createReadStream(".xxx.csv",'utf8');
inputStream.pipe(new csvReader({parseNumbers:true,parseBooleans:true,trim:true}))
.on('data',function(row){
console.log("row ",row);
var no = parseInt(row[0]);
if(Number.isInteger(no)){
console.log(no);
marks.find({"id":no}).toArray(function(err,result){
console.log("entered marks block");
result.forEach(r =>{
updateSubjects(res,row);
//break;
});
console.log("exited marks block")
});
console.log("exited if");
}
})
.on('end',function(){
console.log('No more rows!');
});
console.log("exited upload Data");
I want to get the ID from the excel and want to query the mongodb with the no., but it is not going to the marks block query of mongodb. I knew it is some problem related to async/await and promise, but not sure how to fix this and can’t understand it. Can someone explain me the solution.
Out put is :
- entering the uploadData.
- displaying the id from excel row.
3.. exited the if block.
Not entering the “entered marks block”.
Then iterating to the next row and so on…