I have done research about setValue() and updateChildren(). I have tested both of them to add and update data from firebase database. From what I have learnt that both of them did the same exact thing and did some research about them.
From what I have learnt. The setValue() is used with a class object while updateChildren() is used with a Map or HashMap. Correct me if I'm wrong.
My question is as stated above, what is the difference between setValue() and updateChildren()?
'setValue' method is totally replacing the document (specified reference) with new data.
'updateChildren' method is just updating particular fields or add such fields if they did not exist before.
You often can get the same result using those methods, but actually they are different.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With