I am creating a recipe finding app and basically I have a "favorites" where if the user favorites a recipe, they will be able to easily access it in the favorites tab of the app. Basically this is my structure right now:
app:
users:
2ReAGRZlYiV5F2piwMakz59XDzl1(uid):
favorites:
-KRUe6mMhaQOX62zgXvg(childByAutoId):
ID: 172171 (recipe id)
UTJ0rVst9zMSuQhWkikTCu8558C2(uid):
favorites:
-KRUzMxTvv-uNvX9J9_-(childByAutoId):
ID: 578141 (recipe id)
Basically whenever they go to the favorites tab, I need the list of all the recipe ids so that I can make an API call to retrieve the recipe information. I am basically looping through the dictionary. I also want to be able to allow the user to unfavorite the recipe, so removing it from the database. How will I be able to remove it if I am using:
USERS_REF.child(uid).child("favorites").childByAutoId().setValue(["ID": recipeID])
to add a recipe?
Is there a better structure that I can use to read recipe ids and remove them easily?