I am creating a new document in firebase and like to get the id that I will be creating to save in my collection, however how would I get the same if I have not yet saved it in the database?
Example: the id that will generate will be Iq313NGP4V6jrjdlWn4T, I would like to be able to save this in a variable and pass it 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
})