Is there a way to manipulate the transactions API in the RTDB for "batch" writes?(We currently can't migrate to Firestore)
Our problem is as follows:
When writing a new "Job" object to the server we are preforming three consecuteve writes:
Unfortunately, if one of the writes fails but a previous one succeeded, it causes major bugs in the system.
We are looking for ways to ensure the completeness, or reverting the operation if one of the writes fails.
Clean up unused dataPeriodically remove any unused or duplicate data in your database. You can run backups to manually inspect your data or periodically back it up to a Google Cloud Storage bucket. Also consider hosting stored data through Cloud Storage for Firebase.
The Firebase Realtime Database is a cloud-hosted NoSQL database that lets you store and sync data between your users in realtime. NEW: Cloud Firestore enables you to store, sync and query app data at global scale.
256 MB from the REST API; 16 MB from the SDKs. The total data in each write operation should be less than 256 MB. Multi-path updates are subject to the same size limitation.
If it is just a matter of writing and "ensuring the completeness, or reverting the operation if one of the writes fails", you can use a simultaneous update by using the update()
method.
As detailed in the documentation, "simultaneous updates .... are atomic: either all updates succeed or all updates fail.". See this part of the documentation: https://firebase.google.com/docs/database/web/read-and-write#update_specific_fields
Note that the Real Time Database also offers the possibility to save data as transactions, see the documentation items here and here. But probably, in your case, using simultaneous updates will be sufficient.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With