简体   繁体   中英

Firebase, save data in a unique key

I have this function, and I'm trying to save the data inside the child ('Alunos"), in a unique key. I tried, but I couldn't save with the key

salvarDados() {

    ... data ...

    firebase.database().ref('Usuarios').child(idUsuario).child('Alunos') "UNIQUE KEY" .set({
        imagem,
        nome,
        idade,
        altura,
        peso
    })
}

To generate a unique key, call push() instead of set ():

firebase.database().ref('Usuarios').child(idUsuario).child('Alunos').push({
    imagem,
    nome,
    idade,
    altura,
    peso
})

For more on this, see:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM