exceljs icon indicating copy to clipboard operation
exceljs copied to clipboard

can't get counter value

Open mhmmdakbr opened this issue 7 years ago • 0 comments

I want to ask, I made a func to convert xlsx files to database. when res.send({desc : `${count} data, ${matchcount} data`}) the count and matchcount are 0, even though insert or update to db success so if i console.log this is what works =

  1. convert xlsx to rowarray
  2. this send a response directly
  3. insert db update process

this is my code =

 var matchcount = 0; //match counter
    var count = 0; //counter
   //convert xlsx file to rowarray
   await workbook.xlsx.readFile(req.file.path)
   .then(workbook => {
       workbook.eachSheet(async (sheet, id) => {
           sheet.eachRow(async (row, rowIndex) => {
                  if (isOVO) {
                     ///insert import function///
                     count++
                     for (var i = 0; i < dataKonekthing.length; i++) {                     
                         if (isSameData) {
                             ///insert match data func///
                             ///update import data func///
                             matchcount ++
                          }
                     }         
                 }
            })
         })
   //send response 
     })
   .then(() => res.send({desc : `${count} data, ${matchcount} data`}))

i'm new in nodejs , so please help me solve this problem sorry for my bad english

mhmmdakbr avatar Oct 11 '19 06:10 mhmmdakbr