问题
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