How to tell which descendants are changed with on(“child_changed”)

后端 未结 2 785
半阙折子戏
半阙折子戏 2020-12-15 11:33

For example, I have following database structure:

/ 
+ users
  + 1
    + items
      + -xxx: \"hello\"
  + 2
    + items

Then;



        
2条回答
  •  长情又很酷
    2020-12-15 11:51

    Andrew Lee gave a nice answer, but I think you should try to use cloud functions. something like this should work:

    exports.getPath = functions.database.ref('/users/{id}/items/{itemId}')
    .onWrite(event => {
      // Grab the current value of what was written to the Realtime Database.
      const original = event.data.val();
      console.log('user id', event.params.id);
      console.log('item id', event.params.itemId);
    });
    

提交回复
热议问题