简体   繁体   English

如何使用云功能查找特定子级的Firebase实时数据库

[英]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.

相关问题 如何使用Firebase云功能在DataSnapshot中查找特定值 - How to look for a specific value in a DataSnapshot with Firebase Cloud Functions Firebase的云功能:如何为所有子项的特定子键触发数据库功能 - Cloud Functions for Firebase: How do I trigger a database function for a specific child key of all children 如何使用云函数从我的 Firebase 实时数据库中 database.ref 正在侦听的节点内部获取数据? - How can I fetch data from inside a node which the database.ref is listening to in my Firebase real-time database using cloud functions? 使用Vue将新子项添加到实时Firebase数据库中 - Adding a new child to a real-time Firebase database using Vue 如何取消订阅嵌套实时 firebase 云 Firestore 数据库? - how to unsubscribe nested real time firebase cloud firestore database? 如何使用NodeJS中的Firebase云功能从Firebase实时数据库中找出最近的位置LatLng - How to find out nearest location LatLng from firebase real-time database using firebase cloud function in NodeJS 如何使用云功能将新数据推送到Firebase实时数据库中? - How to push new data into firebase realtime database using cloud functions? 如何使用Google Cloud功能查询Firebase实时数据库 - How to query Firebase Realtime database using Google Cloud functions 在Firebase实时数据库上记录当前秒数的云功能 - Cloud function that logs current seconds on firebase real time database 每次在 firebase 实时数据库中添加新子时,使用 firebase 函数发送推送通知不起作用 - sending push notification using firebase functions every time a new child is added in firebase realtime database is not working
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM