以下是firebase中我的类的结构:
{
"groups" : {
"-KjkdYVP3N69GaDfLwS1" : {
"groupname" : "Ballet Class",
"description" : "8 years onwards",
"picture" : "assets/img/dance.jpg",
"type" : "dance"
},
"-KjkdYVP3N69GaDfLwS2" : {
"groupname" : "Ballet Class",
"description" : "8 years onwards",
"picture" : "assets/img/dance.jpg",
"type" : "dance"
},
"-KjkdYVP3N69GaDfLwS3" : {
"groupname" : "Ballet Class",
"description" : "8 years onwards",
"picture" : "assets/img/dance.jpg",
"type" : "dance"
},
"-KjkdYVP3N69GaDfLwS4" : {
"groupname" : "Ballet Class",
"description" : "8 years onwards",
"picture" : "assets/img/dance.jpg",
"type" : "dance"
}
},
"linking" : {
"DCuf5MvTlpQa0LC4BoJWedIiFfc2" : {
"groupid" : {
"-KjkdYVP3N69GaDfLwS1" : true,
"-KjkdYVP3N69GaDfLwS2" : true,
"-KjkdYVP3N69GaDfLwS3" : true,
"-KjkdYVP3N69GaDfLwS4" : true
},
"memberid" : {
"-KjkdduprKpr8e0P7KH1" : true,
"-KjkdduprKpr8e0P7KH2" : true,
"-KjkdduprKpr8e0P7KH3" : true,
"-KjkdduprKpr8e0P7KH4" : true
},
"role" : "admin",
"uid" : "DCuf5MvTlpQa0LC4BoJWedIiFfc2"
}
},
}
我有2个课程,并且连接了#39;和'团体'。一旦用户登录,我想从链接表中获取用户组的详细信息,并且还希望根据第一个查询的组ID返回来获取组详细信息。我独立编写了这两个查询:
从链接类中获取组: - this.groupid = this.af.database.list(' / linking /' + uid +' groupid);
获取群组的详细信息: this.groupdetails = this.af.database.list(' / groups' + this.groupid);
但我知道这段代码无效。
有人可以建议正确的方法来处理这个要求吗?
我最终想在页面上显示组详情
<li *ngFor="let group of groups| async">
{{ (group.data | async)?.field }}
答案 0 :(得分:0)
var groups = [];
this.af.database.object('linking/'+ uid).subscribe(linking=>{
linking.groupid.forEach(groupid=>{
groups.push(this.af.database.list('/groups'+groupid));
})
})
这可以让您了解如何检索数据。干杯:)