Strapi doesn't support transactions, so what are my options?

Lack of transactions is the only thing keeping me from using Strapi. I’m working on a website, where I need to limit the number of entries. I need to:

  1. Begin transaction
  2. Check the entry count
  3. If there’s still available spots, add the entry to entries
  4. End transaction.

Without a transaction, I could end up with too many entries, if I get a lot of server hits (between step 2 and 3.)

Is there any workaround?

I’m building the frontend in ASP.NET Core with Razor Pages, and was interested in Strapi for the backend.

Have a look here:

And I found this code here:
https://www.codegrepper.com/code-examples/javascript/transaction+strapi

Bottom line there is that you have to use underlying knex orm directly which kind of sucks because you essentially jumping down one level of abstraction, bypassing the whole “Strapi” layer but it seems to be the only way.
Sad though, because 1) Strapi does not have a nice and clean support for a fundamental DB mechanism like transaction 2) Can’t really find any documentation on this topic in strapi docs.

@DMehaffy good sir, is there any plan to bring support for transactions to Strapi in v4? Or perhaps a documentation update?

1 Like

Would need to check with @alexandrebodin since we are currently rewrite the database layer for v4

Please stop pushing new features and fix the ******* bugs! Holy hell, I swear every time I’ve used this library there’s some awful application breaking bug or undocumented nonsense.

:rofl:
I can empathise with the “undocumented nonsense” but can’t recall any bug or anything like that.

1 Like