I have a scenario where each user in my Firebase database can have their own set of recipes, and they can also add recipes from other users to their fav_recipes. Now, I have made changes to an attribute of one of the recipes (For example I change name of recipe), and I need to update all the user’s fav_recipes (with updated name) that include this specific recipe. Here is my firestore schema.
How can I efficiently achieve this in my Firebase database using Swift?
2
Answers
There’s no specific built-in operation to perform such a bulk update. You will have to:
Single source of truth! You should only have to update in 1 spot.
You shouldn’t have several copies of the same thing you can use
DocumentReference
to link favorites to the actual recipe.or something like
So you can query the recipe using an
ID
that does not change.