如何在Firestore上列出子集合? [英] How to list subcollection on firestore?

查看:94
本文介绍了如何在Firestore上列出子集合?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

collection/document/collection/document

user/teamname/username/info

我想列出teamname document的收藏集.我需要收藏集名称.下面的函数返回undefined.

I want to list teamname document's collections.I need collection names. Below functions return undefined.

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:{}

推荐答案

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

Retrieving a list of collections is not possible with the mobile/web client libraries. You should only look up collection names as part of administrative tasks in trusted server environments. If you find that you need this capability in the mobile/web client libraries, consider restructuring your data so that subcollection names are predictable.

检索子集合的方法仅在服务器库(Java,Nodes.js和Go)上可用.您还无法列出客户端库的子集合.

Methods to retrieve subcollections are only available on server libraries (Java, Nodes.js and Go). You can't yet list subcollections with client libraries.

这篇关于如何在Firestore上列出子集合?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆