Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AQL query with updatingdocuments from two collections runs as transaction or not?

I have a question about transactions in arangodb, if I run below AQL query, will it be executed as one transaction or will it be separated into two transaction? My backend is php:

LET r1 = (FOR u IN Users UPDATE u WITH { status: "inactive" } IN Users)
LET r2 = (FOR b IN Blogs UPDATE b WITH { status: "inactive" } IN Blogs)
RETURN true

For now I am using transaction as arangodb documentation suggests (using javascript code), but if using AQL query is possible, I'd prefer to remove js code from my php code!

If it's possible, do you suggest this solution for commiting transactions or using js way is preferred?

like image 268
Amirreza Shafaat Avatar asked Dec 13 '25 04:12

Amirreza Shafaat


1 Answers

AQL in a single server environment is executed in an ACID fashion. This is automatically within a single transaction without any further need of a separate _executeTransaction. Therefore you can use the above AQL statement to update the two collections within a single AQL statement.

There are some caveat to keep in mind:

  • after the update statement for a collection you cannot use this particular collection in any further update or read statement
  • if you enable intermediate commits then the update will no longer be atomic
like image 53
Frank Celler Avatar answered Dec 15 '25 16:12

Frank Celler



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!