Cloud Functions for Firebase iterate through a child node

扶醉桌前 提交于 2021-02-20 09:09:29

问题


I just started to use firebase Functions and I am new to the node.js environment, can somebody tell how to iterate through a child node and get the child values.


回答1:


see this example:

  const parentRef = admin.database().ref("path");
  return parentRef.once('value').then(snapshot => {
      const updates = {};
      snapshot.forEach(function(child) {
        updates[child.key] = null;
      });
      return parentRef.update(updates);
  });



回答2:


Have you looked through the Cloud Functions for Firebase Samples? They contain many helpful examples of common operations. The code in this sample shows some of what you are looking for.



来源:https://stackoverflow.com/questions/43418242/cloud-functions-for-firebase-iterate-through-a-child-node

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!