Provide a golang example to pass data out of firestore transaction #3777
Labels
priority: p3
Desirable enhancement or fix. May not be included in next release.
samples
Issues that are directly related to samples.
triage me
I really want to be triaged.
type: feature request
‘Nice-to-have’ improvement, new feature or different behavior or design.
Please provide an officially suggested way to pass data out of transactions for Go Firestore SDK.
The documentation https://firebase.google.com/docs/firestore/manage-data/transactions#passing_information_out_of_transactions first states
Do not modify application state inside of your transaction functions. Doing so will introduce concurrency issues, because transaction functions can run multiple times and are not guaranteed to run on the UI thread. Instead, pass information you need out of your transaction functions
and then seems to provide meaningful examples for Java or Javascript.But for Go it currently points to this snippet. This snippet seems irrelevant to the section title: it doesn't pass any data out, but rather shows how to update something conditionally within the transaction.
Also given that the transaction callback has type
func(ctx context.Context, tx *firestore.Transaction) error
it doesn't even seem possible to return any data out of transaction and the only way is to literally modify the app state (e.g. some out of scope variables) and access it after the transaction is finished.The text was updated successfully, but these errors were encountered: