I have a problem with firebase Realtime database using html/js. I'm trying to add a data like a colours of pattern but every time it overwrites the same node for example.
Patterns
Monopattern
colour: white
when I try to add colour black it overwrite the white to black I'm searching for a way to set a specific name to name "colour" to add it as a child of the Monopattern.
function add_colours(){
set(ref(db,"Patterns/"+ patt_name.value),{
Colour : patt_color.value
})
.then(()=>{
alert("success");
})
.catch(()=>{
alert("Unsuccessful addition, error:"+error);
})
}
If you want to create a new node under the pattern name, you can use the push function like this:
set(push(ref(db,"Patterns/"+ patt_name.value)),{
Colour : patt_color.value
})
Every time you call push(), Firebase generates a unique key under the path you specify.