title: Sqlite transactions in nodejs
body: <p>Accordingly with nodejs sqlite library (<a href="https://github.com/mapbox/node-sqlite3" rel="nofollow">https://github.com/mapbox/node-sqlite3</a>) you can serialize a sql transaction with db.serialize function. All executions in this function will be executed in the specified order.
  But with a for loop how can i get the information about the transaction will be success or fail?</p>
  
  <pre><code>function transaction(callback) {
      db.serialize(function() {
          db.run("BEGIN");
  
          for(...) {
              db.run("INSERT", function(err) {
                  //this code is not serialized with the parent serialize function (this is my problem)
                  //if one run throw error i must resolve the callback with the error code
  
                  if (err)
                      callback("error");
              });
          }
  
          db.run("END");
  
          callback("ok");
      }
  }
  </code></pre>