【问题标题】:How to list subcollection on firestore? [duplicate]如何在firestore中列出子集合? [复制]
【发布时间】:2018-01-25 10:13:57
【问题描述】:
collection/document/collection/document

user/teamname/username/info

我想列出teamname document 的收藏。我需要收藏名称。以下函数返回未定义。

firestore.collection('user')
.doc('teamname').onSnapshot((data) => { console.log(data) });

firestore.collection('user')
.doc('teamname').get().then((data) => { console.log(data) });

日志:

_data:undefined
_metadata: {}
_ref:{}

【问题讨论】:

  • 在字段部分保存子目录的名称,然后从数据实例 documentSnapshot.data!!.keys.forEach { println(it) } 中获取列表

标签: javascript firebase google-cloud-firestore


【解决方案1】:

Firestore documentation上有提到:

无法通过移动/网络检索收藏列表 客户端库。您应该只查找集合名称作为 受信任服务器环境中的管理任务。如果你发现 您需要在移动/网络客户端库中使用此功能,请考虑 重组您的数据,以便子集合名称是可预测的。

检索子集合的方法仅适用于服务器库(Java、Nodes.js 和 Go)。您还不能列出带有客户端库的子集合。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-03-17
    • 2019-09-01
    • 2021-12-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多