I'm looking to try, for the first time, a JavaScript MVC framework like Knockout, Backbone.js, Spine, JavaScriptMVC, etc.
I've started looking at some of the documentation available for these frameworks and I'm having trouble finding examples of how they handle relational data. Most of them use a ToDo list as an example. A ToDo list is nice, but it doesn't cover relational data. Perhaps a better example would be a cookbook with a model for both 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 for models that I've seen so far do not seem to deal with the problems of relationships: foreign keys, id generation, etc. The example above is a many-to-many relationship, but I would be happy with support even for one-to-many relationships.
I really like the things provided by these frameworks:
- changes to the models automatically update the view (i.e. DOM)
- automatically updating the model on the server when it changes
- clear organization of code
- etc...
But, I'd like advice on which framework best handles relationships between models and has an example where that is done.
Thanks!