如何从firebase数据库中部分提取数据 [英] How to pull the data partially from firebase database

查看:162
本文介绍了如何从firebase数据库中部分提取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从firebase数据库中提取整个数据,并在没有更改数据的情况下访问它。

I wanna pull whole data from the firebase database and access that without change data.

firebase.database().ref(‘someBigNode’).once(‘value’, (snapshot) => {
    //do something
}

但它会花费很多内存。

请问如何部分提取整个数据并节省内存?

May I ask how to pull whole data partially and save memory?

推荐答案

当您使用JavaScript(或iOS或Android)SDK从Firebase数据库读取数据时,它将始终读取完整的节点。所以唯一的方法检索更少的数据是检索JSON树中较低的节点。

When you read data from Firebase Database with the JavaScript (or iOS or Android) SDK, it will always read complete nodes. So the only way to retrieve less data is to retrieve a node lower in the JSON tree.

如果您发现需要在 someBigNode下检索每个节点的一部分,你应该将每个节点的那部分拆分成他们自己的 importantBitsOfSomeBigNode 的顶级节点。

If you find you need to retrieve a part of each node under someBigNode, you should split that part of each node out into a top-level node of their own importantBitsOfSomeBigNode.

遗憾的是,如果没有更具体的数据结构示例和正在尝试的内容,很难提供更多帮助检索(以及这些位特殊的原因)。

It's unfortunately hard to be more helpful without a more concrete example of your data structure and the bits you're trying to retrieve (and the reason why those bits are special).

这篇关于如何从firebase数据库中部分提取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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