I am trying to filter my docs in firebase firestore by checking if a doc 'users' array contains the user's email address. The 'chat' collection contains docs with ids: '[email protected]:[email protected]' and a doc contains messages and users stored in array.
I would like to list chats for the current user.
The problem is that every time I would like to use the where() clause I get to following error:
TypeError: firebase_app__WEBPACK_IMPORTED_MODULE_1___default.a.firestore(...).collection(...).where(...).onSnapshot(...).catch is not a function
This is my code:
firebase.firestore().collection("chats").where("users", "array-contains", currentUser.email)
.onSnapshot(async res => {
setChats(res.docs)
})
.catch(function (error) {
console.log("Error getting documents: ", error);
});