I have a table and in each row there is one meal. Each meal consist of many ingredients. I want to be able to either delete ingredient and to delete meal. How should the state and the delete ingredient function look like?
Should the state look like this:
{
meals: [{name:'breakfast', id:11}, ...]
ingredients: [{name: 'eggs', id:111, meal_id:11}...]
}
or this:
{
meals: [{
name:'breakfast',
ingredients: [{name: 'eggs'}]
}]
}
I think that the second option is better. And the most important question: How should the delete ingredient function looks like? Should each ingredient has its own unique id and should I dispatch a delete action passing ingredient id?