6

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

2 Answers 2

7

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); }); 
Sign up to request clarification or add additional context in comments.

2 Comments

This code will simply remove all the data from my path. So why would i want that?
It's just an example of how to iterate through a child node and get the child values
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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.