"Database Transaction" functionality
Hi,
How does this functionhttps://docs.xano.com/working-with-data/functions/database-requests/database-transaction work if a non-DB function fails?
If this happens:
- Edit record in user table
- Create a variable
test
equal to an empty object{}
- Create another variable equal to variable
test.name
, which fails becausename
isn't intest
Does step 1, Edit Record, get committed to the database?
Thank you!
Best Answer
-
Hi @sepirak-nick if any function nested inside the database transaction fails, then all DB functions will NOT get committed. Everything needs to be successful for the DB functions to be committed.
Answers
-
Thank you, @Michael Udinski
What if the DB edit function is in a nested function? For example, I had the following stack:
1. Database Transaction
1.1 Edit User
1.1.1 Edit Record (DB transaction) ← Actually makes the DB update
1.1.2 Return User record with addon ← DB Get record
1.2 <Some statement that throws an error>
Does the nested Edit Record function get committed? -
No, the nested Edit Record function would not get committed in this case because it's still dependent on the "parent" DB transaction, which is throwing an error in 1.2
Categories
- All Categories
- 53 ? Announcements
- 47 ? Releases
- 37 ? Welcome
- 983 ? Help! I'm a Noob
- 125 ? No-Code Front-Ends
- 633 ? Working with APIs
- 439 ? Transforming data
- 126 ? Connect Xano to ...
- 50 ?? Find an Expert
- 348 ❓Other questions
- 35 ? Security
- 22 ✂️ Snippets
- 19 ? Showcase
- 7 ?️ Xano Chatter
- 62 ? Video Tutorials
- 171 ? Request a feature
- 229 ? Report a Bug
- 19 ? Templates & Extensions
- 7 ? Feedback