Cloud functions for Firebase iterating through child node

I just started using firebase functions and I am new to node.js environment, can someone tell me how to iterate through the child node and get the child values.

+3


source to share


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);
  });

      

+5


source


Have you looked at Cloud Functions for Firebase Samples ? They contain many useful examples of common operations. The code in this example shows some of what you are looking for.



+2


source







All Articles