0👍
Every time you call set
with a reference, it replaces any existing data at that ref
.
If you want to create a new unique child nodes under the ref, use push
instead of set
.
push(userRef, data)
Also see the Firebase documentation on appending to a list of data.
Using an array notation like you’re trying won’t work unless you first read the existing data from the location. Trying to do this is an antipattern in Firebase though, so I also recommend reading Best Practices: Arrays in Firebase.
Source:stackexchange.com