Firebase的Cloud Functions通过子节点进行迭代 [英] Cloud Functions for Firebase iterate through a child node
本文介绍了Firebase的Cloud Functions通过子节点进行迭代的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我刚开始使用firebase函数,并且对Node.js环境不熟悉,有人可以告诉我如何遍历子节点并获取子值.
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.
推荐答案
请参见以下示例:
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);
});
这篇关于Firebase的Cloud Functions通过子节点进行迭代的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文