Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a golang example to pass data out of firestore transaction #3777

Open
myproblemchild opened this issue Feb 14, 2024 · 0 comments · May be fixed by #3785
Open

Provide a golang example to pass data out of firestore transaction #3777

myproblemchild opened this issue Feb 14, 2024 · 0 comments · May be fixed by #3785
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.

Comments

@myproblemchild
Copy link

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.

@myproblemchild myproblemchild added priority: p3 Desirable enhancement or fix. May not be included in next release. triage me I really want to be triaged. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. labels Feb 14, 2024
@product-auto-label product-auto-label bot added the samples Issues that are directly related to samples. label Feb 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant