PDA

View Full Version : Chunked Associative Store Data



volte
28 Sep 2011, 1:04 PM
Hello folks!

I'm hoping my title was accurate. I'll try to explain a little more about what I mean.

For simplicity sake, I will only use two Models.

1. Member
2. Threads

Two Stores:

1. MemberStore
2. ThreadStore

Now, what I want to do, is to set up a relation between the two models, but I want each store to be responsible for pulling down the data it needs (think separate tables in the db, relations to be reconstructed on the front end).

I've been playing around with my stores and models, but when I say Thread.get('Member'), it returns an undefined object (and subsequently baulks at me).

Is what I'm even trying to do, possible, or must I make a HUUUGE data request that will take forever to download (all nested associations in JSON)?

Cheers!

~ Dale

volte
4 Oct 2011, 2:25 PM
From my experience browsing these forums, many threads go unanswered. This seems really weird; as if there is only a ghost of a community. I don't understand that as the site and the framework are so professionally done.

Anyhow, so I managed to get most of my app working, but I'm still stuck on this data association issue.

Is there a specific order that I need to load the data in? Or perhaps, once all the data is loaded into the stores, is there a function I can call that will iterate through all the data and make the appropriate connections/relations?

I find it difficult to believe that the framework expects me to duplicate shared data in the request. What is the point of this relational data framework if it doesn't assuage the massive data call that would normally be required?

If I set up a relationship between two models, and I load data into both of them, shouldn't it just automagically make and find the relationship based on my specifications?

In addition, perhaps a more concrete problem a guru or user out there could help me with; I'm mildly confused as to which model is being referred two when I use the 'foreignKey' property when setting up my relationships. For instance,

App.models.Group = Ext.regModel('Group',{
belongsTo: { model: 'Group', name: 'under', foreignKey: 'under' },

hasMany: [
{ model: 'Member', name: 'members', foreignKey: 'group' },
],

fields: [
{ name: 'id', type: 'string' },
{ name: 'name', type: 'string' },
{ name: 'short', type: 'string' }
],

validations: [

]
});

My "Member" class has a key in it called "group" which links to the id of the Group. Given this, is my association set up correctly?

(Note, yes, groups are recursive, they can belong to another group).

I'd appreciate any and all feedback!

Cheers!

dark_night
24 Nov 2011, 5:30 AM
If I set up a relationship between two models, and I load data into both of them, shouldn't it just automagically make and find the relationship based on my specifications?

You need to define relationships between the instances of the model.
For example when you created instances of Group and Member named "firstGroup" and "firstMember" call

firstGroup.members().add(firstMember);