Apstrata allows you to run multiple operations on the documents of your store within transactional boundaries. When executing operations in a transaction, Asptrata "write-locks" the corresponding documents and applies the effect of the operations as soon as the transaction is committed (i.e. validated), or discards it if the transaction is rolled-back (i.e. invalidated). Transactions can be created from within your Apstrata server-side scripts or from the client side, by invoking the Transaction API, however, it is preferable to only create them in your scripts.
Example: create a new game instance and save the player's name and location
You are developing a cool mobile game. Let us imagine that whenever a player creates a new instance of this game, you would like to save the instance status and the player's name and location in two distinct documents. However, you also need to make sure that both documents get created together, so you do not end up with orphan games. Let us see how to do this using an Apstrata script.