为大型数据集获取numChildren [英] Getting numChildren for large data sets

查看:43
本文介绍了为大型数据集获取numChildren的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个可能有成千上万个子节点的节点,我需要能够仅下载其拥有的子节点数,而无需下载整个数据.

I have a node that can potentially have tens of thousands of Children, I need to be able to just fetch the number of children it has without downloading the whole data.

据我了解,使用on('value')函数以及使用DataSnapShot.numChildren()会导致该节点的整个数据首先被下载,然后进行计数.

From what I understand using the on('value') function and using DataSnapShot.numChildren(), will cause the whole data of that node to be downloaded first before counted.

推荐答案

使用on('value')确实可以下载整个节点.但是您可以使用其REST API的 shallow 功能来仅下载密钥,然后可以进行计数.

Using on('value') would indeed download the entire node. But you can use the shallow feature of their REST API to download only the keys, which you can then count.

curl 'https://samplechat.firebaseio-demo.com/.json?shallow=true&auth=CREDENTIAL'

这篇关于为大型数据集获取numChildren的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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