title: How to write a Mysql transaction within a static JS-method?
body: <p>I have this static method that executes a SQL statement:</p>
  <pre><code>static save(habit){
      return db.execute(
          'INSERT INTO habits (name, repeatVal, notification, color, question, id) VALUES (?, ?, ?, ?, ?, ?)',
          [habit.name, habit.repeatVal, habit.notification, habit.color, habit.question, habit.id]
      );
  }
  </code></pre>
  <p>Instead of this SQL statement I want to do the following SQL Transaction instead (this includes dummy data as of now):</p>
  <pre><code>START TRANSACTION;
  SELECT @habitId:=MAX(habits.habitId)+1 FROM habits;
  INSERT INTO habits(habits.habitId, habits.name, habits.repeatVal, habits.notification, habits.color, habits.question, habits.id) VALUES(@habitId, 'mysql test', 1, 1, '#786578', 'backend hello world', 14);
  INSERT INTO habit_status(habit_status.habitId, habit_status.date, habit_status.status) VALUES(@habitId, &quot;2021-04-01&quot;, 0), (@habitId, &quot;2021-04-01&quot;, 0), (@habitId, &quot;2021-04-01&quot;, 0), (@habitId, &quot;2021-04-01&quot;, 0), (@habitId, &quot;2021-04-01&quot;, 0), (@habitId, &quot;2021-04-01&quot;, 0), (@habitId, &quot;2021-04-01&quot;, 0), (@habitId, &quot;2021-04-01&quot;, 0);
  COMMIT;
  </code></pre>
  <p>What's the correct syntax to do this?</p>