[英]Flutter DocumentSnapshot
I am trying to get the data from a DocumentSnapshot from firebase. 我正在尝试从Firebase的DocumentSnapshot获取数据。
Firestore.instance.collection('products').document("Lucius_Malfoys_Zauberstab").get().then((DocumentSnapshot ds) {
print(ds.exists);
});
This method works totally fine and returns true, but: 此方法可以正常工作并返回true,但是:
var keys = ["Lucius_Malfoys_Zauberstab"];
String id = keys[0];
print(id); ---> prints Lucius_Malfoys_Zauberstab
Firestore.instance.collection('products').document(id).get().then((DocumentSnapshot ds) {
print(ds.exists);
});
returns false... 返回假...
Does anyone have an idea, why this is the case? 有谁知道,为什么会这样? It is just a small problem in my application, but I am curious why this happens.
这只是我的应用程序中的一个小问题,但我很好奇为什么会发生这种情况。 Just for understanding.
只是为了理解。 Thank you!
谢谢!
EDIT: 编辑:
Here is a screenshot of the cart collection: 这是购物车集合的屏幕截图:
Here is a screenshot of the products collection: 这是产品集合的屏幕截图:
I can't reproduce the problem. 我无法重现该问题。 The best I can do at this point is show you what I've done:
此时,我能做的最好的事情就是向您展示我所做的事情:
The first print of false
is before I had the document. false
的第一张印刷品是在我拿到文件之前。 I then created the document, ran _test
again, and it printed true
. 然后,我创建了文档,再次运行
_test
,并将其打印为true
。
If I remove my permission on /55652643/{document}
, the print
statement isn't reached, and instead I get a stack trace that permission has been denied. 如果我删除了对
/55652643/{document}
许可,则不会达到print
语句,而是得到了堆栈跟踪,表明该许可已被拒绝。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.