vendredi 25 avril 2014

Associations - examples/docs needed

In these times of NoSQL and alternatives to relational databases.....

I'm trying to wrap my head around this whole new Associations/Schema affair.


It looks promising, but I find myself confused by lack of docs, examples and the general overview.


Looking at data.Model I see that belongsTo, hasMany and associations are available as configs.


But, looking at the examples in schema.ManyToMany there suddenly is a manyToMany-config available on data.Model.


And then, just to make everything seem completely arbitrary and random, you have the examples in schema.ManyToOne. Where/why am I supposed to specify this? No coffee in the world could help me.


Consider the following:



Code:



{
"items":[
{
name: "foo",
greatness: "extreme",
subItems: [
{
text: "bar"
},
{
text: "barred"
},
{
text: "barring"
}
]
},
{
name: "footer",
greatness: "not so much",
subItems: [
{
text: "garr"
},
{
text: "garrred"
},
{
text: "garrring"
}
]
}
]
}

I know that in Ext 5 I can just dump this into a store.Items which creates model.Item and subItems would be available as raw data. But what if I want subItems cast to be of type model.SubItem? In this scenario there are no id's, and the entire data-structure is dumped in one go.

I could of course just parse this with a convert on the subItems-field in the model.Item, and create the models.SubItem on the fly.


What other alternatives are there?


It would be hardcore awesome if ids, relationships and the store containing all the SubItems, with references to its owner, could be configured with just a few lines.





Aucun commentaire:

Enregistrer un commentaire