java - 如何在 Firebase 中仅获取子 key

标签 java android json firebase firebase-realtime-database

Firebase database

我只想显示位置的子代,即信德和旁遮普(不是他们的子代)。这可能吗?如果可以我该怎么做?

最佳答案

来自Best practices for data structure在文档中:

Avoid nesting data

Because the Firebase Realtime Database allows nesting data up to 32 levels deep, you might be tempted to think that this should be the default structure. However, when you fetch data at a location in your database, you also retrieve all of its child nodes. In addition, when you grant someone read or write access at a node in your database, you also grant them access to all data under that node. Therefore, in practice, it's best to keep your data structure as flat as possible.

这就是 Firebase 的工作原理:如果您获得一个项目,您也会获得它的子项目。如果您不希望这样,您应该重组数据库。

关于java - 如何在 Firebase 中仅获取子 key ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44561416/

相关文章:

java - 使用谷歌gson的hashmap中的json数组

java - 使用 Java 8 Streams 将模型列表转换为具有内部映射的映射

java - 使用 spring boot 和 kotlin 进行单元/休息测试的艰苦战斗

java - 在java中把_放在变量前面有什么意义?

java - 如何使用 SQL 数据库在 Fragment 上创建 Adapter ListView?

android - RecyclerView 与 ImageViews,触摸缩放

android - 我想使用 post 方法发送图像

javascript - 在母版页中注入(inject)json数据

java - 服务如何无限期运行并允许在android中绑定(bind)?

java - 从 servlet 创建自定义 json