Get data through 2 layers of relations with a for loop

Acess data through 2 layers of relations

Hey Glide experts, I have a problem I can’t find a solution for:

My users have selected recipes to cook for their meals for the next week
Each recipe has a certain number of ingredients
I want them to click on a button and that will generate a shopping list with all ingredients to buy in the right quantities

My tables are:

  • Users
  • Recipes (has all recipes)
  • Ingredients (has all ingredients)
  • Meals (has a day and a user)
  • Ingredient in recipe (a row links an ingredient to a recipe with a quantity)
  • Recipe in meal (a row links a recipe to a user’s meal)

My problem is that I need a list of recipes in all meals, and then get all ingredients from all these recipes, with their quantities

I thought a good way to do this was to add a row to a table for every ingredient in a user’s shopping list but Glide doesn’t do that

Does anyone have an idea?
Thanks :slight_smile: