admin管理员组

文章数量:1303498

How to get only changed value on Firebase Database? Because every time I changed a value on dir, ex:

/ some_user
 ~ id
 ~ name
 / data
   ~ order_id
   ~ order_name <<= Changed in here

But when I get the changed data, I get all the tree structure and not only changed data order_name. So I just wanted it to return something like this:

/ some_user
     / data
       ~ order_name <<= Specific changed data

So I can identify what is the exact key data that has changed. How can I do this? Thanks.

How to get only changed value on Firebase Database? Because every time I changed a value on dir, ex:

/ some_user
 ~ id
 ~ name
 / data
   ~ order_id
   ~ order_name <<= Changed in here

But when I get the changed data, I get all the tree structure and not only changed data order_name. So I just wanted it to return something like this:

/ some_user
     / data
       ~ order_name <<= Specific changed data

So I can identify what is the exact key data that has changed. How can I do this? Thanks.

Share Improve this question edited Oct 7, 2016 at 2:44 AL. 37.8k10 gold badges146 silver badges285 bronze badges asked Oct 6, 2016 at 8:22 Muhamad YuliantoMuhamad Yulianto 1,6633 gold badges24 silver badges33 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 7

Attach the listener to the order_name reference.

var user = "Alan";
var ref = firebase.database().ref(user + "/data/order_name");

ref.on("value", function(snapshot) {
    console.log(snapshot.val());
});

本文标签: javascriptHow to get only changed value on Firebase DatabaseStack Overflow