Firebase的Cloud Functions迭代子节点

Ste*_*ong 5 node.js firebase google-cloud-functions

我刚开始使用firebase函数,我是node.js环境的新手,有人可以告诉如何遍历子节点并获取子值.

Die*_*o P 7

看这个例子:

  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);
  });
Run Code Online (Sandbox Code Playgroud)


Bob*_*der 2

您是否浏览过Firebase 示例的云功能?它们包含许多有用的常见操作示例。此示例中的代码显示了您正在寻找的一些内容。