【发布时间】:2020-08-11 14:54:30
【问题描述】:
我正在尝试从 StreamBuilder 查询子集合,但查询返回零个文档,尽管子集合中有一个文档。查询父集合返回正确数量的文档,并且已验证传递给子集合的文档 ID。我错过了什么?
StreamBuilder<QuerySnapshot>(
stream: _firestore
.collection('books')
.document(documentID)
.collection('enquiries')
.snapshots(),
builder: (context, snapshot) {
if (!snapshot.hasData) {
return Text('You have not received any enquiries yet!');
} else {
final numberOfDocs = snapshot.data.documents.length;
print(numberOfDocs); // HELP HERE! returns 0, although a document exists in the subcollection
print(documentID); // returns the expected document ID
...
【问题讨论】:
-
添加你的firestore
-
@PeterHaddad - final _firestore = Firestore.instance;抱歉,StackOverflow 的新用户进行了多次编辑
-
我们可以查看您的 Firestore 仪表板的屏幕截图以及 documentID 的值吗?
-
@dshukertjr:我已经添加了图片,但它们显示为链接,因为我是 Stack Overflow 上的新用户
-
@yesharish 谢谢。这很有帮助!
标签: firebase flutter dart google-cloud-firestore stream-builder