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

fix: async transactional #147

Merged
merged 1 commit into from Aug 7, 2020

Conversation

rafilong
Copy link
Contributor

@rafilong rafilong commented Aug 7, 2020

Expected usecase of AsyncTransactional is as follows, update implementation to await wrapped function.

async def update_data_transaction():
    db = firestore.AsyncClient()
    transaction = db.transaction()
    city_ref = db.collection(u'cities').document(u'SF')

    @firestore.async_transactional
    async def update_in_transaction(transaction, city_ref):
        snapshot = await city_ref.get(transaction=transaction)
        transaction.update(city_ref, {
            u'population': snapshot.get(u'population') + 1
        })

    await update_in_transaction(transaction, city_ref)

@rafilong rafilong added this to the AsyncIO Client milestone Aug 7, 2020
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Aug 7, 2020
@rafilong rafilong merged commit e640e66 into googleapis:v2-staging Aug 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants