title: Use transactions with mariadb and node.js
body: <p>Is there a better way to use transactions with the <a href="https://github.com/mscdex/node-mariasql" rel="nofollow noreferrer">mariasql</a> library than adding <code>BEGIN</code> to the start of the query, and finalizing with either a commit or a rollback?</p>
  
  <p>Currently, if I want to wrap a series of queries in a transaction I have to do something like this:</p>
  
  <pre><code>const MariaClient = require('mariasql');
  let client = new MariaClient();
  
  client.connect({
      host: "127.0.0.1",
      user: "user",
      password: "pass",
      db: "some_db",
      multiStatements: true
  });
  
  client.query('BEGIN; INSERT INTO some_table VALUES ("a0","b0"), ("a1","b1"), ("a2","b2");', function (err) {
      if (err) {
          client.query('ROLLBACK;');
      }
      client.query('COMMIT;');
  });
  </code></pre>
  
  <p>This seems clunky and potentially error prone.  We are using the <a href="https://github.com/coopernurse/node-pool" rel="nofollow noreferrer">generic-pool</a> to manage the mariadb client, so it seems like there could be some unintended consequences handling transactions this way.</p>