Navigation

Write Transactions - .NET SDK

Realm Database uses a highly efficient storage engine to persist objects. You can create objects in a realm, update objects in a realm, and eventually delete objects from a realm. Because these operations modify the state of the realm, we call them writes.

All writes to Realm must be within a transaction. A transaction is a list of read and write operations that Realm treats as a single indivisible operation. In other words, a transaction is all or nothing: either all of the operations in the transaction succeed or none of the operations in the transaction take effect.

Note
Remember

All writes must happen in a transaction.

A realm allows only one open transaction at a time. Realm blocks other writes on other threads until the open transaction is complete. Consequently, there is no race condition when reading values from the realm within a transaction.

When you are done with your transaction, Realm either commits it or cancels it:

  • When Realm commits a transaction, Realm writes all changes to disk. For synced realms, Realm queues the change for synchronization with MongoDB Realm.
  • When Realm cancels a write transaction or an operation in the transaction causes an error, all changes are discarded (or "rolled back").

Realm guarantees that transactions are ACID compliant. This means that all committed write operations are guaranteed to be valid and that clients don't see transient states in the event of a system crash.

Give Feedback

On this page

  • Overview
  • Realm is ACID Compliant