serverless-mysql icon indicating copy to clipboard operation
serverless-mysql copied to clipboard

Multiple transactions

Open amirjrn opened this issue 4 years ago • 2 comments
trafficstars

Hello . Thank you for your nice package!

I want to do a multipe query transaction like below:

DB.query('INSERT into t.billing (name , lastname ) VALUES ('amir' , 'jiryan'); 
          UPDATE t_billing.transactions
           Set deposit = 0,
               final   = 1,
               _lmb    = 27
           WHERE id = 625');

but getting syntax error . Can you please provide the solution?

amirjrn avatar Feb 15 '21 09:02 amirjrn

By the way I really do not need to use transaction in this case . Just need a simple query. Thanks

amirjrn avatar Feb 15 '21 11:02 amirjrn

Something like:


let result = await mysql
  .query( 'INSERT into t.billing (name , lastname ) VALUES ( ? , ? )', [ fname, lname ] )
  .query( 'UPDATE t_billing.transactions Set deposit = 0, final   = 1,  _lmb    = 27 WHERE id = 625' )
  .catch( e => {
    /* do something with error */ 
  })
  .end();

trasherdk avatar Feb 15 '21 12:02 trasherdk