Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cloud Functions for Firebase iterate through a child node

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.

like image 226
Steven Wong Avatar asked Apr 14 '17 19:04

Steven Wong


Video Answer


1 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);
  });
like image 166
Diego P Avatar answered Sep 18 '22 00:09

Diego P