【发布时间】:2017-07-30 21:37:51
【问题描述】:
我正在尝试获取在将项目推送到数据库时由 Firebase 数据库生成的密钥,但是,返回的密钥具有不同的值。在照片中,您可以看到 'key' (-kqI0bxKg...) 的值与推送对象主键的值不同。为什么返回不同的密钥(-kql0bxKgq...)?如何使用 angularfire 和 typescript 解决这个问题?
handler: data => {
this.afAuth.authState.subscribe(auth => {
const currentUser = auth.uid;
var myRef = this.afDatabase.database.ref().push()
var myKey = myRef.key;
console.log(myKey);
var newEntry = {
description: data.description,
number: 0,
createdBy: currentUser,
key: myKey
}
this.afDatabase.list('whatIWant').push(newEntry);
})
}
【问题讨论】:
标签: typescript firebase-realtime-database angularfire