简体   繁体   English

访问 Firebase 实时数据库中的嵌套值

[英]Access nested value in Firebase Realtime Database

I'm a Firebase newbie and I would like to figure out how to access deep nested data in Realtime Database.我是 Firebase 新手,我想弄清楚如何访问实时数据库中的深层嵌套数据。 Let's suppose I have the following structure:假设我有以下结构:

在此处输入图像描述

I would like to get the block of data in which location -> Id value corresponds to 3154380 , (in this case is the second one)我想获取 location -> Id 值对应于3154380的数据块,(在本例中是第二个)

How could achieve this?怎么能做到这一点?

Just put the sub-path in .orderByChild and use .equalTo :只需将子路径放入.orderByChild并使用.equalTo

database().ref('reports').orderByChild('location/id').equalTo('3174380');

However, I will say, you should really look at flattening your data structure for best performance and usability in this environment.但是,我要说的是,您真的应该考虑扁平化您的数据结构,以获得在此环境中的最佳性能和可用性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM