[英]How to look for a specific child the Firebase real time database using cloud functions
I'm trying to make a cloud function that will search for a specific child in my database. 我试图做一个云功能,它将在数据库中搜索特定的孩子。
This is my database structure: 这是我的数据库结构:
places
place_id_1
users
user1
date: 1231233
user2
date: 3213424
place_id_2
users
user3
date: 123442
And what i'm trying to do is search to what node 'user1' is connected ('place_id_1' is this case). 我想做的就是搜索连接到哪个节点“ user1”(在这种情况下为“ place_id_1”)。
It might have a lot of children under 'places' node, so it wont be a good idea to go over all of them (and it can take a lot of time..) 它可能在“地方”节点下有很多孩子,所以遍历所有孩子并不是一个好主意(这可能会花费很多时间。)
Is there a way to easily query and get all the nodes that are associated with a specific user? 有没有一种方法可以轻松查询和获取与特定用户关联的所有节点?
Firebase only allow you to query at 1 level. Firebase仅允许您在1级进行查询。 You will need to create a reference table.
您将需要创建参考表。 Eg:
例如:
usersReference:
user1:
place_01
user2:
place_02
Please have a look here: Firebase Query Double Nested 请在这里看看: Firebase Query Double Nested
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.