gpt4 book ai didi

firebase - 尝试从 firebase 获取单个文档时断言失败

转载 作者:行者123 更新时间:2023-12-04 10:19:44 24 4
gpt4 key购买 nike

我试图从我的 firebase 集合中获取一个文档
但我收到此错误:未处理的异常:PlatformException(Error 5, FIRFirestoreErrorDomain, No document to update
我有一个带有文档 ID 的文档,我通过打印进行了检查
这是我的代码:

  void updateBalanceOfSender() async {
var docID;
Firestore.instance
.collection('balance')
.where('user', isEqualTo: loggedInUser.email)
.snapshots()
.listen((data) =>
data.documents.forEach((doc) => print(docID = doc.documentID)));
_firestore
.collection('balance')
.document(docID)
.updateData({'balance': '1'});
}

最佳答案

您将错误的参数传递给 where 方法。
使用下面的代码:

 void updateBalanceOfSender() async {   

var document = await Firestore.instance
.collection('balance')
.where(“user”,isEqualTo: loggedInUser.email);

print(document);

}

看看 this查看如何执行查询。

This question 也可能有帮助。

关于firebase - 尝试从 firebase 获取单个文档时断言失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60914067/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com