【发布时间】:2014-09-07 02:27:31
【问题描述】:
这是我的模型:
Ext.define('myApp.model.Category', {
extend: 'Ext.data.Model',
requires: [
'Ext.data.Field'
],
config: {
fields: [
{
name: 'id',
type: 'int'
},
{
name: 'slug',
type:'string'
},
{
name: 'title',
type:'string'
},
{
name: 'post_count',
type:'int'
}
],
}});
这是我的商店:
Ext.define('myApp.store.LocalCate',{
extend: 'Ext.data.Store',
requires: [
'Ext.data.proxy.Sql'
],
config: {
autoLoad:false,
model:'myApp.model.Category',
storeId:'LocalCate',
proxy:{
type: 'sql',
database: 'myApp',
table: 'Category'
},
}
});
现在的问题是:
当我使用store.add({id:123,slug:'123',title:'123',post_count:123});
或store.add(Ext.create('myApp.model.Category'{id:123,slug:'123',title:'123',post_count:123});
他们都没有成功;
看来,当我删除“id:123”并只添加数据时
{slug:'123',title:'123',post_count:123}
它成功了,当我执行store.sync() 时,WebSql 数据库显示没有“id”的数据。
我确实知道,如果我将 id 更改为 'cate_id' 之类的其他内容,它将起作用。
但是,我希望这个 'id' 作为 idproperty,并且我不想更改它的名称。
我该怎么办?你如何在sencha touch中使用websql?我在 LocalStorage 中发现了同样的问题。
【问题讨论】:
标签: extjs sencha-touch local-storage store web-sql