Database Transactions
in progress
Daniel Susanu
Hi Guys, I could not find a way of doing a database transaction by reading the documentation. Is this not implemented yet? If not how is such a fundamental functionality of an api not implemented or in the road map?
This should be the highest priority since many people will need this.
Could you please let me know what is the plan for this and how soon is going to be implemented?
Regards,
V
Víctor Martínez Calvo
Is this coming as part of Strapi v5 ?
Marc Roig Campos
While this is still experimental and is subject to changes in the future versions, there is the possibility to use transactions.
We had been using this internally for the past months but I can not give an exact date of when this will released as stable :)
P
Pablo Criado-Perez
Hi, checking in to see if there any updates on the release of transactions?
Harjas Sodhi
Hi! I am looking to implement transactions in my app and found that they are not currently supported, seeing as this thread is old, any updates or any alternative to transactions with strapi v4?
Thanks
Derrick Mehaffy
Merged in a post:
Support Database Transactions with Knex
w
willnode
Please support database transactions in v4. v3 actually supports database transactions since it is used with Bookshelf.js. v4 uses a custom database engine and I can't see how I can insert knex.js transactions in custom code.
Please read my draft article on how to use database transactions in v3, it also tells the real reason why database transactions is a must:
manuelf.
Any news on this ? Would be a blast to have it implemented!
jejom43
Is there any news on this feature?
Derrick Mehaffy
in progress
Daniel Susanu
Hi Guys, what is the status of this?
Alexander
Although I fully support the push for transactions in v4 but I don't think adding low-level (i.e. knex based) transactions to Strapi is the way to go. This will make everyone write low-level db access code/queries that imply knowledge of db schema. Not only this will be prone to errors, it will be also very prone to obsoletion whenever Strapi makes changes in the way they lay the data out in the actual database. Look at v3->v4 example, relations have been given complete rewrite and now any relation end up in the separate table while previously it was not the case. So all my low-level queries that I wrote for performance optimisation were thrown to the rubbish bin during migration. This is what will happen to all of your low-level knex-based transaction queries too.
I believe we, as community, should be pushing for a proper, high-level transactions support where you could do something like
strapi.transaction( (trx) => {
const exists = await trx.query("api::restaurant.restaurant").findOne({where: {id: 1}})
if (!exists) {
await trx.query("api::restaurant.restaurant").create({data: restaurantData});
}
} )
This code will not require rewrite every time strapi updates its version.
Load More
→