-
19 Oct 2011 1:54 AM #11
Updated sqlitproxy compatibale with ST2 class structure.
https://github.com/tomalex0/SenchaTouch-v2-SqliteProxy
-
20 Oct 2011 7:36 AM #12
@tomalex
Thanks for sharing your plugin. I've just started to play with it, and it seems to mostly work, but I've found two details that I thought I should mention.
1. In the updateRecord function, you have this code:
Shouldn't it be:Code:var me = this, id = record.internalId, key = primarykey, modifiedData = record.modified,
Otherwise, in the end you are generating an SQL sentence that tries to compare the 'id' property of the record with an internal Sencha value, not with the value for the 'id' field of the record that we want to modify.Code:var me = this, id = record.get(primarykey), key = primarykey, modifiedData = record.modified,
2. It's a minor detail, but I've changed (on setRecord):
you originally included rs.InsertId in the text that gets evaluated, but it caused problems when minifying the js file (because you are including the name of the variable, that can be modified by the minifier, in plain text).Code:onSuccess = function (tx, rs) { var returnrecord = record, insertId = rs.insertId, json = '{' + primarykey + ' : ' + insertId + '}'; // notice no quotes returnrecord.set(eval("(" + json + ")")); returnrecord.internalId = rs.insertId; },
Regards,
Salva.
-
26 Oct 2011 9:15 PM #13
@salva
Thanks for pointing out those issues.
The issue you pointed out in updateRecord, did you come across this issue?
if you look into setRecord function
this is meant to set the insert id from table to sencha internal id. I thought this should fix the issue that you have pointed out.Code:returnrecord.internalId = rs.insertId;
Regarding issue with minifying the variable , i was actually not aware of those
.
-
26 Oct 2011 9:42 PM #14
@salva
i think record.get(primarykey) , will be better option. I will update my github.
and also get rid of those eval implementation
.
-
1 Nov 2011 12:41 AM #15
@tomalex0
I use your SQLite proxy for PhoneGap database but i don't know how to config it for PhoneGap database .Can you give me a detail example to get your proxy work fine with below database:
Sorry i have just jumped into Sencha Touch and so confuse on make a custom proxy with sencha touch.Code:var db; function connectDB() { db = window.openDatabase("SpotLife_Spot", "1.0", "Spot Database", 5000000); } function populateDB(tx) { tx.executeSql("CREATE TABLE IF NOT EXISTS CAPTUREDSPOT (SpotId unique, Title, Category, Latitude, Longitude, Owner, ImgPath, Tip, DetailAddress)"); } function errorPopulateDB(err){ navigator.notification.alert("Error processing SQL: " + err.toString()); } function createDB(){ connectDB(); db.transaction(populateDB, errorPopulateDB); }
-
1 Nov 2011 1:09 AM #16
Try this
Db Connection
Table Model which creates TableCode:var dbconnval = { dbName: "SpotLife_Spot", dbDescription: "Spot Database" }; Ext.DbConnection = new Ext.Sqlite.Connection(dbconnval);
Code:Ext.regModel('CAPTUREDSPOT', { fields: [{ name: 'SpotId', type: 'int', fieldOption: 'UNIQUE' }, { name: 'Title', type: 'string' }, { name: 'Category', type: 'string' }, { name: 'Latitude', type: 'string' }, { name: 'Longitude', type: 'string' }, { name: 'Owner', type: 'string' }, { name: 'ImgPath', type: 'string' }, { name: 'Tip', type: 'string' }, { name: 'DetailAddress', type: 'string' }], proxy: { type: 'sqlitestorage', dbConfig: { tablename: 'CAPTUREDSPOT', dbConn: Ext.DbConnection.dbConn, }, reader: { idProperty: 'ID' } }, writer: { type: 'json' } }); CAPTUREDSPOTStore = new Ext.data.Store({ autoLoad: true, model: 'CAPTUREDSPOT' });
-
1 Nov 2011 1:12 AM #17
If you are checking in Chrome try this in sqlite console.
Code:SELECT sql FROM sqlite_master WHERE type='table' and name='CAPTUREDSPOT';
-
1 Nov 2011 2:14 AM #18
Thank for your support
. I just don't understand why you override destroy on model and when the destroy function on proxy work .
The destroy function of proxy just only work on model not on store ? If i use "view.store.remove(rec) ; view.store.sync(); ",it still work ? I just get it from this http://edspencer.net/2011/02/proxies-extjs-4.html .Code:if(e.getTarget(".delete")){ var rec = view.store.getAt(index); var user = Ext.ModelMgr.create(rec.data, 'Contacts'); user.destroy(); view.store.remove(rec); }
-
1 Nov 2011 2:44 AM #19
destroy method was missing from STversion 1.1.0, I think it is fixed in v1.1.1. This is needed when we are trying to delete model instance. I haven't think about the sync function after store record is removed.
Thanks for pointing out
.
-
2 Nov 2011 12:49 AM #20
Uncaught TypeError: Cannot read property 'dbConn' of undefined
Uncaught TypeError: Cannot read property 'dbConn' of undefined
I keep getting this error in Chrome console: Uncaught TypeError: Cannot read property 'dbConn' of undefined. The demo provided on github runs file. I'm not even doing anything with the model. And I have quadruple checked to see if all the files are included in index.html.
Any ideas? Is there a problem with doing this in an MVC application?
myModel.js . I keep getting the error at the line "dbConn: Ext.DbConnection.dbConn"
Code:Ext.regModel('sqliteModel', { fields: [ { name: 'firstname', type: 'string' }, { name: 'lastname', type: 'string' }, { name : 'ID', type : 'int', fieldOption: 'UNIQUE' }, { name : 'modifyDate', type : 'string' } ], proxy: { type: 'sqlitestorage', dbConfig: { tablename: 'contactsTable', dbConn: Ext.DbConnection.dbConn, <-------- ERROR HERE!!!! }, reader: { idProperty: 'ID' } }, writer: { type: 'json' } }); BT.stores.InputStore = new Ext.data.Store({ autoLoad:true, model : 'sqliteModel', });
Here is my app.js incase you need it -->
Code:Ext.regApplication({ name : "BT", icon: "resources/images/icons/icon.png", glossOnIcon : false, tabletStartupScreen: 'resources/images/startup/tabletStartupScreen_768x1004_v1.png', phoneStartupScreen: 'resources/images/startup/phoneStartupScreen320x460_v1a.png', launch: function() { Ext.ns('DbConnection'); var dbconnval = {dbName : "btDB", dbDescription: "the Bt database"}; Ext.DbConnection = new Ext.Sqlite.Connection(dbconnval); BT.views.Viewport= new BT.views.Viewport({ fullscreen: true, }); } });


Reply With Quote