【发布时间】:2018-07-25 04:33:18
【问题描述】:
我正在使用此代码更新我的文档。
Future<void> save() async {
print('league save');
final DocumentReference ref =
Firestore.instance.collection('leagues').document(_documentName);
Firestore.instance.runTransaction((Transaction tx) async {
DocumentSnapshot postSnapshot = await tx.get(ref);
if (postSnapshot.exists) {
await tx.update(ref, _getDocument());
print('league save complete');
}
});
}
我相信这有时可能会失败,但我不确定。我遇到了一个错误。
我怀疑它有时会失败的原因是因为我的侦听器(在应用程序的其他地方)并不总是在文档更改时被触发。
如何记录或捕获事务中的错误?
【问题讨论】:
标签: google-cloud-firestore flutter