Im trying to get the data from firebase using an array of indexes as condition.
I have an array of categories and i need to get all the items with the categories from array.One item can have more categories. I have tried something like this but foreach is not doing anything to collection. I understand that you cant pass the array to firebase so i need some other solution.
const getItemsByCategories = (categories: string[]) => {
const collection = db.collection("items");
categories.forEach(category => {
collection.where("category", "array-contains", category);
});
return collection.get().then(mapQuerySnapshot);
};