在您将文档保存到firestore之后,有没有办法获取生成的文档ID?
antiJARLocking
编辑:或者只是
var collection = db.collection("Users").doc();
collection.set({
xxx:"stuff",
yyy:"stuff"
})
.then(function (?Something?)
{
var theIdIWant = ?Something?;
}
)
答案 0 :(得分:7)
doc()的返回值为DocumentReference,其id字段中包含唯一ID。
var doc = db.collection("Users").doc();
doc.set({
xxx:"stuff",
yyy:"stuff"
})
.then(() => {
var theIdIWant = doc.id
})