I have 3 collections:
- User => with some field
- Organization => with some field
- UserOrg with fields like:
- uid // user id
- orgid // orgid
- userDetails // document reference of user doc like user/uid
- orgDetails // document reference of org doc like org/uid
Now I need to fetch user details of user details
My code is:
return this.dbCollectionService.userOrganizationCollection.snapshotChanges()
.pipe(map(res => {
return res.map(data => {
var userData = data.payload.doc.data()
let userDetails : any;
if (userData.userDetails) {
this.angularFirestore.doc(userData.userDetails).valueChanges().subscribe(res => {
userDetails = res;
console.log(userDetails);
});
return { id, ...userDetails }
}).filter( f => f.organizationId != undefined && f.organizationId == orgId)
}));
This is able to console the result correctly, but not returning data.
Could be getting data from data reference taking time and return statement executes earlier.
from Filter on document reference as a field
No comments:
Post a Comment