Feature request · API & developer experience · Blocks work
Atomic increment and decrement for document fields
1 source thread · first seen 2022-09
Summary
The user needs atomic updates such as incrementing a counter, because doing it in server functions cannot prevent race conditions. Firestore offers field increments and transactions for this.
- Affects
- developer building counters like likes
- Workaround
- Update the value from a server function (race-prone)
Evidence
Excerpts are copied word for word from the source; follow the link to read it in full.
“We can do that using server functions at the moment but there is no way to prevent race condition”