Firebase - 用于set()而不是update()的良好用例 [英] Firebase - good use case for set() instead of update()
问题描述
我在使用Firebase的应用中构建了创建,更新和删除操作。关于这个答案关于 set()
和 update()
,@ jmk2142建议在firebase中创建,更新和删除一个项目都可以用 update()
。
除了语义/理解代码的目的,有没有什么好的理由不使用 update()
所有这些?
如果要替换位置中的整个值,则需要使用<$如果要更新位置下的特定属性或路径,请使用。
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?
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()
.
这篇关于Firebase - 用于set()而不是update()的良好用例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!