Why read operations must come before write operations in a firestore transaction?

Viewed 211

In firestore document (https://firebase.google.com/docs/firestore/manage-data/transactions#transactions) it says that: "Read operations must come before write operations". What's the rationale for this rule enforced in the nodejs sdk?

Here's what I know:

What if we remove this empty write batch check? The server sdk will cache all write operations and commit them at the end. What am I missing?

What I'm trying to do is: manage collections in different modules and they need to reuse the same transaction to perform an atomic operation (e.g. create an order and reduce the inventory and subtract user balance); each module need to read from some collections and make some changes.

0 Answers
Related