Problem with localstorage store and model with hasMany association
Is store with 'localstorage' proxy is support a models with hasMany associations?
I have a model with one hasMany association:
Code:
Ext.define('Cart', {
extend: 'Ext.data.Model',
config: {
fields: [
{name: 'id', type: 'string'},
{name: 'created', type: 'date'}
{name: 'status', type: 'boolean'}
],
idProperty: 'id',
identifier: {
type: 'uuid'
},
associations: [
{
type: 'hasMany',
model: 'Product',
associationKey: 'products',
foreignKey: 'cart_id',
name: 'products',
autoLoad: true
}
]
}
});
Ext.define('Product', {
extend: 'Ext.data.Model',
config: {
fields: [
{name: 'product_id', type: 'string'},
{name: 'quantity', type: 'integer'},
{name: 'cart_id', type: 'string'},
],
idProperty: 'product_id',
belongsTo: 'Cart'
}
});
my store with localstorage proxy:
Code:
Ext.define('Cartstore', {
extend: 'Ext.data.Store',
config: {
model: 'Cart',
proxy: {
type: 'localstorage',
id: 'carts'
}
}
});
I tried to add record to store:
Code:
var newCart = Ext.create('Cart', {
'created': new Date(),
'status': true
});
newCart.products().add(Ext.create('Product', {
'product_id': 10,
'quantity': 1
}));
Ext.getStore('Cartstore').add(newCart).sync();
After that I see in localstorage first model data only without associated data.
No errors in console. But no associated data in localstorage.
Where I am wrong?