I'm struggling to filter out only the data relevant to a specific "userId" from Firestore, as currently everything in the database is being printed. I've attempted to make changes based on advice I received but it hasn't resulted in any improvements. I'd greatly appreciate your guidance in fixing this issue.
The TypeScript code for the app component is as follows:
constructor(...) {
this.userId = authService.currentUserId; // for loading user id data
this.userCollection = afs.collection<User>('users/'+this.userId);
this.user$ = this.userCollection.snapshotChanges().pipe(
map(actions => {
return actions.map(a => {
const data = a.payload.doc.data() as User;
const id = a.payload.doc.id;
if (id == this.userId) {
return { id, ...data };
}
});
})
);
}
<ion-item *ngFor="let data of user$ | async">
<ion-label>
{{data.myName}}
<p>{{data.userId}}</p>
</ion-label>
</ion-item>