Advertisement
Guest User

Untitled

a guest
Dec 3rd, 2019
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let isRun = true;
  2. let count = 0;
  3.  
  4. async function dbTransactionTest() {
  5.     await connection.promise().beginTransaction();
  6.     try {
  7.         await connection.promise().query(`INSERT INTO test (gameId, serverId) VALUES ('1', '1');`);
  8.         await connection.promise().commit();
  9.         count++;
  10.     } catch (error) {
  11.         await connection.promise().rollback();
  12.         throw error;
  13.     }
  14. };
  15.  
  16. function test() {
  17.     setTimeout(() => {
  18.         isRun = false;
  19.         console.log(count);
  20.     }, 1000);
  21.  
  22.     while (isRun) {
  23.         dbTransactionTest();
  24.     }
  25. };
  26.  
  27. test();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement