如何通过Firebase Cloud函数将数据写入/更新到多个子节点? [英] How do I write/update data to multiple child nodes via Firebase Cloud functions?

查看:41
本文介绍了如何通过Firebase Cloud函数将数据写入/更新到多个子节点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个看起来像这样的数据库:

I've got a database that looks like this:

我想为数据库中的所有用户在特定时间(例如12 AM)自动将 Patient_List Current_Token 子级重置为0.

I want to reset the Patient_List and Current_Token children to 0 at a particular time (say 12 AM) automatically for all the users in the database.

我浏览了Firebase云功能文档以及gitHub上的以下项目:删除节点删除未使用的使用Cron的用户帐户.以上两个示例均基于特定的UID更新和更改数据,即基于传递的UID仅更新特定的节点.我想知道是否有可能在所有节点中更新上述子元素的值,如果可以,将如何完成?

I went through the Firebase cloud function docs and these projects on gitHub: Deleting nodes and Delete unused user accounts using Cron. Both of the above examples update and change data based on a particular UID i.e update only particular nodes based on the UID passed. I would like to know if it is possible to update values for the above child elements in all the nodes and if so , how would it be done?

推荐答案

不可能有一个单独的update语句影响某个位置下所有数据库节点的子级.您将必须迭代所有节点(通过某种方式查询/读取它们),然后更新找到的每个节点.这可能是花费大量带宽的昂贵操作.

It's not possible to have a single update statement affect a child of all database nodes under some location. You will have to iterate all the nodes (by querying/reading them somehow), then update each one that you find. This is potentially a costly operation in terns of bandwidth.

这篇关于如何通过Firebase Cloud函数将数据写入/更新到多个子节点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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