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.
1 Answer
Reset to default 7Attach 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());
});