I'm trying to query an array of objects from my firestore database, I've tried many methods such as array-contains
, array-contains-any
, in
, but to no avail.
I have a users array, and it's an array of objects, each object has two properties-- id and role. I want to write a query that will selectively get a document in which the current logged in user is present in the user's array.
db.collection('chatRooms')
.where(/* What am I supposed to do here */)
.get()
.then((snapshot) => {
setRooms(
snapshot.docs.map((room) => {
return { id: room.id, data: room.data() };
})
);
});
Here's a snapshot of how I'm storing the data: