0
votes

I am about to set a database and I will have to update it manually by uploading a json file. But unfortunately, manual updates delate and replace data.

So I am wondering... If I set an eventlistener on a key of the database, will it be triggered everytime I update the databse ? Or, will it be smart enough to detect a difference from the previous update ?

Example:

From the update sequence below, if I set an eventlistener on "Key1", which one will trigger the listener ?

Starting point: { "Key1": [ { "data1":"value1", "data2":"value2" } ] }

1st Update: { "Key1": [ { "data1":"value1", "data2":"value2" } ] }

2nd Update: { "Key1": [ { "data1":"value1", "data2":"value2", "data3":"value3" } ] }

3rd Update: { "Key1": [ { "data1":"value1", "data3":"value3" } ] }

Thanks

1

1 Answers

0
votes

You have different types of event listeners. So if you observe with FIRDataEventType.value, you will be notified on every change that happens in the node specified (or its descendants) - in your example, it would be the 2nd and 3rd updates.

But you can choose to be notified only when a child is added, or when it is removed, for example.

You can check their documentation on the FIRDataEventType enum =D