Thursday, 8 June 2017

Node.js Execution order queries

At the end of my code, I have two actions that run at the same time, a query that makes an Atler table. The second insertion.

The problem is that sometimes the insertion happens before the alter table.

How can I execute the first part of the code in the for loop for all keys, then proceed with the insertion ?

if (count >1) {
       for( var i = 0; i < keys.length -1; i++ ) {
         client.execute (queryadd, { prepare: true }, function (err) {
         console.log("do");
         });
       }
    }


 client.execute(queryinsert, { prepare: true }, function (err) {
   console.log(err);
   client.shutdown();
  });



via hm_patmol

No comments:

Post a Comment