Lets say we are working on a recipe app and we have 2 get requests initially. /ingredients/ /recipes/ These create the recipe and the ingredient model. Now recipes are made of ingredients and amount of each ingredient. And ingredients only have names.
Now populating the models are easy using the models and the default serializes and the adapters if we confirm to the https://jsonapi.org/
How do we handle when one of the ingredients is deleted. In the backend I use django if and ingredient is deleted DB also deletes all the recipes that have relation to the that ingredients.
But on the SPA application the let say we ran
ingredient.deleteRecord();
ingredient.get('isDeleted'); // => true
ingredient.save();
or
ingredient.destroyRecord();
How does the recipes model get updated ? So do you manually do what server does on the client(and delete related recipes by custome code)? Or should you just update the list and repopulate it(easier). And can you give dependencies between models so a model in the store would know that it need to be updated when one of it dependencies model is changed so it automatically make a get request and repopulate itself(are routes/models that clever?)
On that note what is the standard way of keeping server and client in sync.
What is the standard for this sort of stuff. Should client app re-get all that data again just to be sure that server and spa are insync and uptodate.
Thanks