I'm trying to understand the new association concept in Extjs 5 data models.
I've got the following models
// User
Ext.define('App.model.User', {
extend: 'App.model.Base',
fields: [
{name: 'id', type: 'string'},
{name: 'name', type: 'string'},
],
manyToMany: {
Categories: {
type: 'Categories',
role: 'categories',
field: 'categories',
right: true
}
}
});
// Category
Ext.define('App.model.Category', {
extend: 'App.model.Base',
constructor: function () {...},
fields: [
{name: 'id', type: 'string'},
{name: 'categoryName', type: 'string'},
]
});
I've got the following json for a user:
{ "user": { "id": "1", "name": "Foo", "categories": [1, 2, 3] } }
When the User
model is loaded it should initialize the categories store with the data.
(My Category
model knows to convert the number to a object of id & categoryName)
For some reason when I try getting the users' categories the store is empty.
userRecord.categories(); // has no records
How can I get this to work?