Reputation: 71
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.
Upvotes: 6
Views: 4488
Reputation: 1758
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);
});
Upvotes: 7
Reputation: 38299
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.
Upvotes: 2