如何使用AngularFire2和Firebase加入两个节点?
问题描述:
我有我的火力地堡数据库的这种结构如何使用AngularFire2和Firebase加入两个节点?
每个图书馆能有几张专辑。我如何显示每个图书馆的相册?
albumsPerLib:
第一个元素是库密钥,并且在每个库密钥的下面存储属于它的专辑密钥。
但我不习惯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);
});
}
见http://stackoverflow.com/questions/30299972/joining-data-between-paths-based-on-id-using-angularfire –
是angularjs不是2 ,而且angularfire1不是2.我还没有处理。我认为但不确定那些旧的没有使用可观察的? – Ron
啊,那确实不同。我想你必须使用'map()'调用,但是我自己只用于同步操作。 –