Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Transactions on documentDB

We have our data stored in documentdb. We do need to perform action that touch mutiple document in one transaction. Is there a way to perform a sqlserver like transaction on documentDB?

like image 533
JVermeulen Avatar asked Jun 30 '16 12:06

JVermeulen


2 Answers

If you execute clientside actions every action is executed independent of a transaction. It is not possible to create a transaction from the client side actions.

To execute mutiple actions in one transaction you need to create a documentDB stored procedure. All actions in a document Stored Procedure are executed similar to a transaction. All actions are executed and if one of them fails, all actions are rolled backed.

For more information how to create and execute stored procedures see: https://azure.microsoft.com/en-us/documentation/articles/documentdb-programming/

like image 186
Sander van den Hoven Avatar answered Sep 28 '22 15:09

Sander van den Hoven


Transactions are handled via stored procedures. The operations within a stored procedure will happen within a transaction.

Just note that, within a stored procedure, any documents you touch can only be within a single collection (or a single partition within a partitioned collection).

like image 23
David Makogon Avatar answered Sep 28 '22 14:09

David Makogon