Hi, I am relatively new to this community. Have learnt the basics but still learning how to apply it all. I want to be able to randomly select a meal from my firebase database and then choose an appropriate meat to align it with but am struggling to do so. Each meal is it’s own document as it has multiple fields within it including Meal_Name, Meat, Carb type (eg. Rice, noodles, pasta), and cooking effort level (low, medium, hard).
So far I created a data variable collection called mealCollection and was able to successfully generate a random meal name using this formula: PICK_ITEM(FLATTEN(MAP(data.mealCollection,item.fields.Meal_Name.stringValue)),RANDOM_INTEGER_BETWEEN(0,pageVars.totalMealsCounter-1))
Essentially the above pulls all the Meal_Name items from each document into a list and randomly picks a meal from that list. It might return a result such as “Stir Fry” which is one of the meal names currently in my data.
I want that random meal to also include the meat being used in front of it. In my database I have set up the Meat item as an array as certain meals like a Stir Fry can be done with multiple meats (eg. Chicken or Beef) so I want it to generate something like “Chicken Stir Fry”. From what I have done above, it compiles all the meal names in a new list and to my knowledge I have no idea how to then reference back to the Meat item data. Any thoughts on how I could approach this? Or maybe restructure it?
Ultimately I want to get to the user being able to select their preferences up front whether they feel like a particular meat, carb, or effort level (can leave blank) and then generate a random answer from the data that fits the preferences. But that might be a few steps later.