0
I’m creating a new document in firebase and likes to take the id I’ll be creating to save in my collection, but how would I get it if I haven’t saved it in the database?
Example: the id you will generate will be Iq313ngp4v6jrjdlwn4t, I would like to be able to save this in a variable and go to cd_id in . set.
var novoProduto = db.collection("/caminho").doc();
novoProduto.set({
cd_categoria: categoria,
cd_id: 'aqui gostaria de ter o id',
ds_descricao: descricao,
ds_nome: nome,
modalidade: "1",
nr_preco: preco
})