runTransaction method
Implementation
Future<void> runTransaction(String collectionPath, String docId) async {
await _db.runTransaction((transaction) async {
DocumentSnapshot snapshot = await transaction.get(_db.collection(collectionPath).doc(docId));
if (snapshot.exists) {
int currentCount = snapshot['count'];
transaction.update(_db.collection(collectionPath).doc(docId), {'count': currentCount + 1});
}
});
}