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

Support Firestore.runTransaction #24

Closed
suztomo opened this issue Feb 26, 2020 · 0 comments · Fixed by #46
Closed

Support Firestore.runTransaction #24

suztomo opened this issue Feb 26, 2020 · 0 comments · Fixed by #46
Assignees

Comments

@suztomo
Copy link
Collaborator

suztomo commented Feb 26, 2020

(I haven’t tested but I assume the function is not implemented yet. So far I don’t use transactions in my Flutter app)

https://firebase.google.com/docs/firestore/manage-data/transactions#transactions

final DocumentReference postRef = Firestore.instance.document('posts/123');
Firestore.instance.runTransaction((Transaction tx) async {
  DocumentSnapshot postSnapshot = await tx.get(postRef);
  if (postSnapshot.exists) {
    await tx.update(postRef, <String, dynamic>{'likesCount': postSnapshot.data['likesCount'] + 1});
  }
});

Excerpt from https://pub.dev/packages/cloud_firestore

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant