问题
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