将文档保存到Firestore后,是否可以获取生成的文档ID?
var collection = db.collection("Users").doc(); collection.set({ xxx:"stuff", yyy:"stuff" }) .then(function (?Something?) { var theIdIWant = ?Something?; } )
编辑:或者
var myID = collection.id
doc()的返回值是一个DocumentReference,在其id字段中具有唯一的ID 。
var doc = db.collection("Users").doc(); doc.set({ xxx:"stuff", yyy:"stuff" }) .then(() => { var theIdIWant = doc.id })
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
点击生成二维码
我来说两句