I want to try the JavaScript MVC framework for the first time, such as Knockout , Backbone.js , Spine , JavaScriptMVC , etc.
I began to study some of the documents available for these frameworks, and itβs hard for me to find examples of how they handle relational data. Most of them use the ToDo list as an example. The ToDo list is good, but it does not cover relational data. Perhaps the best example is a cookbook with a model for recipes and ingredients:
var Recipe = function(){ this.name = "Pizza"; this.description = "A delicious baked, flat, disc-shaped bread topped with tomato sauce and cheese."; } var Ingredient = function(){ this.name = "Tomato sauce" } var IngredientToRecipe = function(){ this.recipe = null; this.ingredient = null; this.quantity; }
The examples of models that I have seen so far do not seem to be relevant to relationship problems: foreign keys, identifier generation, etc. The above example is a many-to-many relationship, but I would be happy with support even for a one-to-many relationship.
I really like the things provided by these frameworks:
- changes in models automatically update the view (i.e. DOM)
- automatic updating of the model on the server when changing
- clear code organization
- etc...
But I would like to get advice on what structure is best to handle the relationship between models, and there is an example where this is done.
Thanks!
source share