Is there a way to get the generated doc Id after you've saved a document to firestore?
var collection = db.collection("Users").doc();
collection.set({
xxx:"stuff",
yyy:"stuff"
})
.then(function (?Something?)
{
var theIdIWant = ?Something?;
}
)
Edit: Or just
var myID = collection.id
The return value from doc() is a DocumentReference which has the unique id in its id field.
var doc = db.collection("Users").doc();
doc.set({
xxx:"stuff",
yyy:"stuff"
})
.then(() => {
var theIdIWant = doc.id
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With