如何从flutter firestore中读取子集合。我正在使用cloud_firestore。我正在成功地将数据添加到firestore中,但无法检索到它(尝试并失败)。我想检索名为subCollection Firestore collection的产品
我试过了,我没有文档ID,因为它是从firestore自动生成的:
Stream<QuerySnapshot> loadorderdetails(String uid) {
return FirebaseFirestore.instance
.collection('Users/$userid/Orders')
.doc()
.collection("Products")
.where('uid', isEqualTo: uid)
.snapshots();
}发布于 2021-04-04 08:33:08
你应该试试这个
FirebaseFirestore.instance.collection("Users/$userid/Orders ").get().then((querySnapshot) {
querySnapshot.docs.forEach((result) {
FirebaseFirestore.instance
.collection("Users/$userid/Orders")
.doc(result.id)
.get()
.then((querySnapshot) {
//print data
});
});
});
});https://stackoverflow.com/questions/66936846
复制相似问题