doc: update transaction example

This commit is contained in:
Marc-Roig 2023-05-23 12:42:55 +02:00
parent bff6d9a24a
commit 39dae2b701
No known key found for this signature in database
GPG Key ID: FB4E2C43A0BEE249

View File

@ -89,7 +89,7 @@ await strapi.db.transaction(async ({ trx, rollback, commit }) => {
## When to use transactions
Transactions should be used in cases where multiple operations should be executed together and their execution is dependent on each other. For example, when creating a user registration form, the transaction can be used to ensure that data is only committed to the database if all fields are properly filled out and validated.
Transactions should be used in cases where multiple operations should be executed together and their execution is dependent on each other. For example, when creating a new user, the user should be created in the database and a welcome email should be sent to the user. If the email fails to send, the user should not be created in the database.
## When not to use transactions