Angular 在集合之间联接数据(外键)

Angular 在集合之间联接数据(外键),angular,firebase,ionic-framework,google-cloud-firestore,rxjs,Angular,Firebase,Ionic Framework,Google Cloud Firestore,Rxjs,这是我的数据库: 我想在我的订阅源上显示所有服务的列表(获取服务信息+获取用户信息并合并它们) 这是我的密码: this.afStore .collection(“服务”) .valueChanges() .烟斗( switchMap((服务)=>{ constuserid=uniq(services.map((sv)=>sv.userId)); 返回CombineTest([of(服务)), 组合测试([ userId.map((userId)=> 这家商店 .collection('us

这是我的数据库:

我想在我的订阅源上显示所有服务的列表(获取服务信息+获取用户信息并合并它们) 这是我的密码:

this.afStore
.collection(“服务”)
.valueChanges()
.烟斗(
switchMap((服务)=>{
constuserid=uniq(services.map((sv)=>sv.userId));
返回CombineTest([of(服务)),
组合测试([
userId.map((userId)=>
这家商店
.collection('users',(ref)=>
ref.where('id','=',userId)
)
.valueChanges()
.pipe(映射((用户)=>用户[0]))
),
]),
]);
}),
地图([服务,用户])=>{
返回服务.map((服务)=>{
控制台日志(服务);
返回{
服务
user:users.find((u:any)=>u.id==service.userId)作为UserModel[],
};
});
})
)
.订阅((结果)=>{
this.joined=结果;
console.log(this.joined);
});

I get user:undefined

在您的图片中,您选择的服务的用户ID为
In3Vw…
。但是,您的用户似乎没有具有此id的用户。您确定该用户存在吗
users.find
在未找到具有给定条件的元素时返回
undefined