问题
I'm building create, update and delete operations in my app that uses Firebase. Regarding this answer on a question about the difference between set()
and update()
, @jmk2142 suggested that creating, updating and deleting an item in firebase could all be done with update()
.
Apart from semantics / understanding the purpose of the code, is there any good reason NOT to use update()
for all of these?
回答1:
If you want to replace the entire value in a location, you'll want to use set()
.
If you want to update specific properties or paths under a location, use update()
.
来源:https://stackoverflow.com/questions/45940176/firebase-good-use-case-for-set-instead-of-update