Firebase - good use case for set() instead of update()

会有一股神秘感。 提交于 2019-12-13 07:24:56

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!