简体   繁体   English

Firestore 中的路径

[英]Path in Firestore

I want to get file from firestore with path: images/flowers.我想从 firestore 获取文件,路径为:images/flowers。 How can I get into 'flowers' subcollection?我怎样才能进入“花”子系列? I need it as snapshots.我需要它作为快照。

I tired this but didn't work:我累了,但没有工作:

Firestore.instance
            .collection('images')
            .document()
            .collection('others')
            .snapshots()

I want to get path to the subcollection 'others':我想获得子集合“其他”的路径:

在此处输入图片说明

You have to specify what document you want to get.您必须指定要获取的文件。 If you want the 'others'-collection for all of them you first need to get the previous collection and iterate over them or better yet, set up a StreamBuilder.如果您想要所有的“其他”集合,您首先需要获取以前的集合并迭代它们,或者更好的是,设置一个 StreamBuilder。

If you want to build a path to a subcollection, you need to know all of the path components.如果要构建子集合的路径,则需要了解所有路径组件。 Right now, you are ignoring the required document ID under which the subcollection is nested.现在,您忽略了嵌套子集合所需的文档 ID。 Passing no arguments to document() will just generate a random document ID, which obviously won't exist at the time of the query.不向document()传递任何参数只会生成一个随机的文档 ID,这在查询时显然不存在。 If you don't know the full path to a collection, then you won't be able to query it.如果您不知道集合的完整路径,那么您将无法查询它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM