I have a collection 'chats' with a members array which contains users participating in the chat. The problem is I want to get all chats where the current user is participating.
I do this with this query:
getUserChats(): Observable<Chat[]> {
return this.auth.currUser
.pipe(
take(1),
switchMap(user => this.afs
.collection('chats', ref => ref.where('members', 'array-contains', `/users/${user.uid}`))
.snapshotChanges()
.pipe(
map(actions => {
return actions.map(action => {
const data = action.payload.doc.data() as Chat;
const id = action.payload.doc.id;
return {id, ...data};
});
})
) as Observable<Chat[]>
)
);
}
This works well for strings, but doesn't work with References. How can I also make it work on References?
The green works the red one doesn't work
Green: String Red: Reference