简体   繁体   English

在ionic3上使用firebase时获取密钥

[英]get the key while using firebase on ionic3

I'm using firebase on my ionic project. 我在离子项目上使用Firebase。 You can see my dataset on firebase with the following image. 您可以使用以下图像在firebase上查看我的数据集。

I want to get the $key to update the specific data. 我想获取$ key更新特定数据。 How can i get it? 我怎么才能得到它?

You can check my code how to get datas from firebase. 您可以检查我的代码如何从Firebase获取数据。

getPaymentsFromArchive() {
    const userid = this.authData.showUser().uid;
    let profileData: any[] = [];

this.angularFireDatabase.list(`/users/${userid}/userPayments/${this.selectedYears}/${this.selectedMonths}/userSubscriptions`).subscribe(data => {
        profileData = data;
      });
}

在此处输入图片说明

I want to get $key: "-L-hLB5VKoYRxKEvlNYj" 我想获取$ key: "-L-hLB5VKoYRxKEvlNYj"

在此处输入图片说明

If you want all the keys in userSubscriptions this should work. 如果您希望userSubscriptions所有键都可以使用。

this.angularFireDatabase.list('/users/${userid}/userPayments/${this.selectedYears}/${this.selectedMonths}/userSubscriptions').subscribe(data => {
    profileData = data;    
    profileData.map(item => {
       console.log(item.$key);
    })
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM