When we write software, we always want to make it as flawless as possible. While we always strive for it hard enough, sometimes bugs still can appear in a production system. So this is why, when we write software, we have to prepare for the worst when things go wrong.
I’m have tested your code, but the rollback does not work.
return await strapi.db.connection.transaction(async (transacting) => {
// Find the user
try{
const fromUser = await strapi.query('api::local.local').create({ data:{id:444 }}, null, { transacting });
const toUser = await strapi.query('api::local.local').create({ data:{id:999 }}, null, { transacting });
// respond with the receipt (don't forget to sanitize our output!)
return "worked"
}
catch(e){
return e
}
});
here, the id 999 already exists in the database, and it returns duplicated key error, however, the id 444 is inserted before this error and not removed when the transaction fails.
Try discord, although your experience will most likely be similar.
The question to answer ratio here and in discord is pretty sad, yes.
I found better results arrive if you mention people. Specifically Derrik (DMehaffy). He is the most responsive person out of entire company and out of entire forum to be honest. This guy clearly cares but he is just one human being and there are this many questions
HI @Filipe_Cunha and sorry for the late reply. We are currently organizing a process to be more responsive and the author has been notified. If you’re stuck, as @aveprik mentioned, Discord is the best place to get help, our Solutions Engineers @DMehaffy, @Richard_Nsama and @bolg55 will do their best to help you out.
After you do so, use the patch-package library as explained in the docs (patch-package - npm) to generate a patch that contains a diff of the original @strapi/database package version and your local modified one.
Then you commit the generated patch to your repo so that whenever you run npm install the patch-package re-apply the changes on top of the clean strapi release.