Flutter DocumentSnapshot

2019-08-18 05:50发布

I am trying to get the data from a DocumentSnapshot from firebase.

Firestore.instance.collection('products').document("Lucius_Malfoys_Zauberstab").get().then((DocumentSnapshot ds) {
          print(ds.exists);
        });

This method works totally fine and returns true, but:

      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:

enter image description here

Here is a screenshot of the products collection:

enter image description here

1条回答
手持菜刀,她持情操
2楼-- · 2019-08-18 06:43

I can't reproduce the problem. The best I can do at this point is show you what I've done:

enter image description here

The first print of false is before I had the document. I then created the document, ran _test again, and it printed 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.

查看更多
登录 后发表回答