title: NodeJs: `beginTransaction` is not a function error in mysql2
body: <p>In my below code, I am getting the error <code>is not a function</code>. This error is thrown in the line <code> await con.promise().beginTransaction();</code> please check my code below.</p>
  <pre><code>const mysql = require('mysql2');
  const errorCodes = require('source/error-codes');
  const PropertiesReader = require('properties-reader');
  
  const prop = PropertiesReader('properties.properties');
  
  
  const con = mysql.createPool({
      connectionLimit : 10,
      host: prop.get('server.host'),
      user: prop.get(&quot;server.username&quot;),
      password: prop.get(&quot;server.password&quot;),
      port: prop.get(&quot;server.port&quot;),
      database: prop.get(&quot;server.dbname&quot;)
  });
  
  
  exports.checkInvestorBoost = async (event, context) =&gt; {
  
      context.callbackWaitsForEmptyEventLoop = false;
      con.config.namedPlaceholders = true;
  
      const params = event.queryStringParameters;
  
  
      if (!params || params.iduser == null) {
          var response = errorCodes.not_null_parameters;
          return response;
      } else {
          if(isNaN(params.iduser))
          {
              var response = errorCodes.missing_fields;
              return response;
          }
          const iduser = Number(params.iduser);
          const toDate = new Date();
  
          console.log(&quot;iduser: &quot; + iduser);
  
          let sql = &quot;SELECT * FROM golden_circle_member WHERE iduser= :iduser AND is_investor_boost = true AND to_date &gt; :to_date&quot;;
  
  
          try {
              await con.promise().beginTransaction();
              const [data, meta] = await con.promise().query(sql, {
                  iduser: iduser,
                  to_date: toDate 
              });
  
              // commit and complete
              await con.promise().commit();
              let output= false;
  
              if(data.length&gt;0)
              {
                  output = true;
              }
  
              var response = {
                  &quot;statusCode&quot;: 200,
                  &quot;headers&quot;: {
                    &quot;Content-Type&quot;: &quot;application/json&quot;
                  },
                  &quot;body&quot;: JSON.stringify({
                      &quot;is_investor_boost&quot;: output
                  }),
                  &quot;isBase64Encoded&quot;: false
                };
  
              return response;
  
          } catch (error) {
              console.log(error);
              var response = errorCodes.internal_server_error;
              return response;
          }
      }
  };
  </code></pre>
  <p>Reading about the question, I figured out that when <code>createPool</code> is used, I need to get the connection first. Not sure how I can get that done. Plus, I prefer to do this with <code>async/await</code></p>
  <p>Appreciate your advice here</p>