Best Practices
3. Data Modeling and Sync Logi...
Batch Write Transactions
use a write transaction when you want to combine multiple database operations into a single atomic transaction cross collection operations the legacy query api methods support atomic operations across collections for more information, see ditto store write in your language's api reference c ross collection atomic write transactions are currently unsupported by ditto query language (dql); development is actively in progress implementing global async transactions all write transactions are event driven, or asynchronous, but locally scoped by default when you have many documents to write to a peer, you can initiate a transaction in a way that avoids blocking or slowing down the main thread of your app by starting the transaction asynchronously; as in, it can occur concurrently with other ditto operations for example, in swift, use dispatchqueue global , as follows dispatchqueue global(qos default) async { ditto store write { transaction in let scope = transaction scoped(tocollectionnamed "passengers \\(thisflight)") // loop inside the transaction to avoid writing to database too frequently self passengers foreach { scope upsert($0 dict) } } } log message transaction remains blocked if you have a queued write transaction that remains blocked, the following message appears in your logs log level waiting for write transaction (elapsed xxs), originator=user blocked by=user i f you see this message in your ditto logs, read the docid\ rqb6iuxxq4uoplk4ss7sk guide for more information about how to debug blocked database transactions