Add Firestore transaction example (#442)
diff --git a/packages/cloud_firestore/CHANGELOG.md b/packages/cloud_firestore/CHANGELOG.md index 65f1513..46f73a3 100644 --- a/packages/cloud_firestore/CHANGELOG.md +++ b/packages/cloud_firestore/CHANGELOG.md
@@ -1,3 +1,7 @@ +## 0.7.0+1 + +* Add transactions example to README. + ## 0.7.0 * **Breaking change**. `snapshots` is now a method instead of a getter.
diff --git a/packages/cloud_firestore/README.md b/packages/cloud_firestore/README.md index 7085989..eeae48b 100755 --- a/packages/cloud_firestore/README.md +++ b/packages/cloud_firestore/README.md
@@ -62,6 +62,18 @@ } ``` +Running a transaction: + +```dart +final DocumentReference postRef = Firestore.instance.document('posts/123'); +Firestore.instance.runTransaction((Transaction tx) async { + DocumentSnapshot postSnapshot = await tx.get(postRef); + if (postSnapshot.exists) { + tx.update(postRef, <String, dynamic>{'likesCount': postSnapshot.data['likesCount'] + 1}); + } +}); +``` + ## Getting Started See the `example` directory for a complete sample app using Cloud Firestore.
diff --git a/packages/cloud_firestore/pubspec.yaml b/packages/cloud_firestore/pubspec.yaml index 4dc4152..14d53f7 100755 --- a/packages/cloud_firestore/pubspec.yaml +++ b/packages/cloud_firestore/pubspec.yaml
@@ -3,7 +3,7 @@ live synchronization and offline support on Android and iOS. author: Flutter Team <flutter-dev@googlegroups.com> homepage: https://github.com/flutter/plugins/tree/master/packages/cloud_firestore -version: 0.7.0 +version: 0.7.0+1 flutter: plugin: