我的 Firebase 数据库有这样的结构
每个库可以有多个专辑。如何显示每个库的专辑?
albumsPerLib:
第一个元素是库 key ,在每个库 key 下面,我存储属于它的专辑 key 。
但我不习惯 NoSQL,无法弄清楚如何连接表来显示每个库的专辑。
最佳答案
所以这有效:
getAlbumsThatBelongToLib(libKey:string):Observable<Album[]>{
//get the keys for the lib albums
const albumsPerLib$ = this.db.list(`albumsPerLib/${libKey}`);
//map the returned list of keys
//and get their details from the albums node
return albumsPerLib$
.map((albumKeys) => albumKeys
.map( (albumKey) => {
return this.db.object(`albums/${albumKey.$key}`)
}))
.flatMap((res) => {
return Observable.combineLatest(res);
});
}
关于javascript - 如何使用 AngularFire2 和 Firebase 连接两个节点?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40999531/