I have a collection called chats, I want to listen on the document for changes in the msg while also returning the data from the msg field, I have come up with a query but I am not getting the result I want. below is the code.
getCurrentMsgs(chatId){
return this.firestore.collection('chats', ref => ref.where('id', '==', chatId))
.snapshotChanges()
.pipe(
map(actions => {
return actions.map(a => {
// eslint-disable-next-line @typescript-eslint/ban-types
const data: Object = a.payload.doc.data();
const id = a.payload.doc.id;
return { id, ...data };
}
);
})
);
}