I have a web application that utilises two collections in a MongoDB database:
- Ingredients
- Recipes
An example of the problem
- A chef creates a new recipe, which is added to the Recipes collection.
- The recipe is automatically classified as vegetarian, because it contains only vegetarian ingredients.
- A vegetarian user adds the chef's recipe to their favourites - an array of IDs referencing their favourite recipes.
- The chef updates their recipe to include meat.
- The vegetarian user unexpectedly sees a non-vegetarian recipe in their favourites.
I would like for the vegetarian user to:
- See that a recipe in their favourites has been updated, but
- Continue be able to view the recipe they favourited.
I hope this make sense.
Please can someone in the know help me understand a scalable way of tackling this problem? This system will eventually contain millions of recipes.