這是我的模型:我如何在煎茶觸摸使用的WebSQL唯一ID
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更改爲「cate_id」之類的其他名稱,它將起作用。 但是,我希望將'id'作爲id屬性,並且我不想更改它的名稱。 我該怎麼辦?如何在sencha touch中使用websql?我在LocalStorage中發現了同樣的問題。