Search code examples
mysqltransactionsstrapi

Transaction using strapi


I am learning to use strapi, and have a question. How I do the database transaction like commit & rollback when using strapi & mySql ?

Thank You


Solution

  • You can create a transactions as follows

    await strapi.connections.default.transaction(
              async (trx) => {
                    //functions inside transaction
                    await trx.raw("insert into table..............")
              });