Firebase push() and set()

巧了我就是萌 提交于 2019-12-23 02:36:13

问题


I'm writing a bit of React code to push text to firebase and I've seen a couple different ways of doing this. I think the difference is set() overwrites the data at location while push will add it to the location under whatever is already there, however I then came across

this.ref.push().set({text: text});

which uses both, so now I'm a bit confused what that does compared to just set() and push() Any help is appreciated


回答1:


Calling ref.push().set({text: text}) in the Firebase JavaScript SDK does the exact same ref.push({text: text}). It's just a shorthand notation.



来源:https://stackoverflow.com/questions/47125842/firebase-push-and-set

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