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
- 1Cloud Functions for Firebase allow for quite a broad set of use-cases. Without seeing the minimal code that reproduces where you are stuck it is unlikely that we'll be able to answer better than what the documentation already does.Frank van Puffelen– Frank van Puffelen2017-04-15 05:38:08 +00:00Commented Apr 15, 2017 at 5:38
Add a comment |
2 Answers
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 Comments
Fayza Nawaz
This code will simply remove all the data from my path. So why would i want that?
Diego P
It's just an example of how to iterate through a child node and get the child values
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.