What Javascript MVC framework best handles relational data?

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!

+4
source share
3 answers

Sproutcore has a client-side data warehouse that allows you to link different model objects to each other in toOne, toMany, and ManyToMany relationships. You really can write queries to the repository that are automatically updated when data changes. Similarly, if you perform an update and modify a model object, any views attached to this model (through the controller) will be automatically updated). In addition, SC has an embedded repository functionality that makes it easy to discard changes for workflows such as "save or cancel."

http://guides.sproutcore.com/records.html

+1
source

While Backbone ( intentionally ) does not support models that contain other models / collections very well, Backbone-relational adds support for it and works quite well. Check their documentation.

+2
source

I don’t think you are looking for MVC as such, I think you are looking for something with a good β€œM”. So you can search for something like our Ext JS model associations. (Ext JS is, of course, a full-fledged structure, so if you want to sprinkle something on top of jQuery, this will not be for you.)

Here is the documentation for models in Ext JS 4 and here is the top-level guide for Ext JS 4 MVC

0
source

All Articles