title: Howto wait for query execution on database?
body: <p>my code is:</p>
  
  <pre><code>        jsonArray.forEach(function (that) {
              db.each(sql, function (err, row) {
              }, function (err, rows) {
                  console.log("111");
              });
          });
          console.log("222");
  </code></pre>
  
  <p>after running first write is 222.
  How to wait for db.each to write 111 then 222?
  thanks</p>
  
  <p><strong>EDITED:</strong></p>
  
  <p><code>console.log("222");</code> is after loop.</p>