[英]Creating key in firestore
我想在 Firestore 的集合中設置實際值之前生成一個密鑰。 在 firebase 中,語法類似於firebase.database().ref().child('myposts').push().key
。
我怎樣才能在firestore
中做到這一點。
我用...
構造函數(私有 afs:AngularFirestore){}
pushkey = this.afs.createId()
那么你可以做
this.afs.collection("你的收藏").doc(this.pushkey).add({id:this.pushkey, name: "chris"})
在 Firestore 中,您可以調用add()
生成隨機密鑰來推送數據。
JavaScript 中的示例
db.collection('pathRef').add({
...
}).then(function(docRef) {
...
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.