How Can I use database transaction in strapi V4?

System Information
  • Strapi Version: 4.0.7
  • Operating System:
  • Database: postgres
  • Node Version: 14.17.3
  • NPM Version: 8.3.0
  • Yarn Version: 1.22.17

strapi.db.getConnection().transaction(async (transacting) => {
await strapi.db.query(‘api::style.style’).create({
data: {
name: ‘test-A’,
},
}, { transacting })
const aaa = await strapi.db.query(‘api::style.style’).update({
where: {
id: 4
},
data: {
name: ‘test-B’,
}
}, { transacting });

    return aaa

})

I use it like this,but it`s not work

2 Likes

Just found out v4 doesn’t support transactions yet

And they dont even plan to implement it…
Im still using strapi V3 because of this…