Firestore provides two methods for writing multiple documents at once: Batched Writes
and BulkWriter
.
Let's understand them in more detail:
In Firestore, batched writes are a way to perform multiple write operations as a single atomic unit. A batch of writes completes atomically and can write to multiple documents.
- Atomicity: All writes in the batch will either succeed or fail together. If any operation fails, the whole batch fails, and changes are not applied.
- Limitations: There's a limit of 500 operations per batch. Each operation in the batch counts separately, so a batch of 500 operations can be made up of any combination of
set()
,update()
, ordelete()
operations.