title: Node mysql TypeError: conn.beginTransaction is not a function
body: <p>I have a mysql query I am trying to perform with node-mysql that uses a transaction. It should be on the connection object, but the error I am getting says that it doesn't have a begin transaction method.</p>
  
  <p><code>TypeError: conn.beginTransaction is not a function</code></p>
  
  <p>Here's the transaction code:</p>
  
  <pre><code>dbutil.transaction(req.db, 
  
      function(done){
  
          req.db.query('INSERT INTO answers (question, user, background, importance, comment) values (?, ?, ?, ?, ?)',
              [question, user, background, concurrence, importance, comment],  function (err, result){
                  console.log('result from insert query: ', result);
                  console.error('error: ', err);
                  done();
              // req.db.query('INSERT INTO concurrenceAnswers (concurrence) values (?)',
              //     [concurrence], function (err, result){
              //         console.log('result form insert query: ', result);
              //         console.error('error: ', err);
  
              // })
  
          });
  
  
      }, function(){}
  
      );
  </code></pre>
  
  <p>And the transaction method: </p>
  
  <pre><code>exports.transaction = function(conn, body, done) {
      conn.beginTransaction(function(err) {
          if (err) return done(err);
  
      body(function(err) {
          if (err) return conn.rollback(function() {
              done(err);
          });
  
          conn.commit(function(err) {
              if (err) return conn.rollback(function() {
                  done(err);
              });
  
              done();
          });
      });
  });
  };
  </code></pre>
  
  <p>Req.db.query is:</p>
  
  <pre><code>var db = mysql.createPool({
  connectionLimit: config.db.connectionLimit,
  host:            config.db.host,
  user:            config.db.user,
  password:        config.db.password,
  database:        config.db.database,
  port:            config.db.port
  </code></pre>
  
  <p>});</p>