Rua*_*uan 2 firebase reactjs google-cloud-firestore
在将文档保存到firestore后,有没有办法获取生成的文档ID?
var collection = db.collection("Users").doc();
collection.set({
xxx:"stuff",
yyy:"stuff"
})
.then(function (?Something?)
{
var theIdIWant = ?Something?;
}
)
Run Code Online (Sandbox Code Playgroud)
编辑:或者只是
var myID = collection.id
Run Code Online (Sandbox Code Playgroud)
doc()的返回值是一个DocumentReference,它的id字段中有唯一的id .
var doc = db.collection("Users").doc();
doc.set({
xxx:"stuff",
yyy:"stuff"
})
.then(() => {
var theIdIWant = doc.id
})
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1920 次 |
| 最近记录: |