1. #11
    Sencha User tomalex0's Avatar
    Join Date
    Apr 2009
    Location
    San Jose, CA
    Posts
    589
    Vote Rating
    16
    tomalex0 will become famous soon enough

      0  

    Default


    Updated sqlitproxy compatibale with ST2 class structure.

    https://github.com/tomalex0/SenchaTouch-v2-SqliteProxy
    Sencha Touch Demos

    IosToggleField Forum - Github
    Form Validation
    Forum - Github
    Iphone Settings Menu
    Forum
    Sqlite Storage & Login Manifest
    Forum
    KitchenSink MVC
    Forum - Github
    SqliteProxy-v1 Forum - Github
    SqliteProxy-v2
    Forum - Github
    Arshaw Fullcalendar Forum - Github






  2. #12
    Touch Premium Member
    Join Date
    May 2007
    Posts
    22
    Vote Rating
    1
    Salva is on a distinguished road

      0  

    Default


    @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:

    Code:
            var me = this,
                id = record.internalId,
                key = primarykey,
                modifiedData = record.modified,
    Shouldn't it be:
    Code:
            var me = this,
                id = record.get(primarykey),
                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.

    2. It's a minor detail, but I've changed (on setRecord):
    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;
                },
    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).

    Regards,
    Salva.

  3. #13
    Sencha User tomalex0's Avatar
    Join Date
    Apr 2009
    Location
    San Jose, CA
    Posts
    589
    Vote Rating
    16
    tomalex0 will become famous soon enough

      0  

    Default


    @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

    Code:
    returnrecord.internalId = rs.insertId;
    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.


    Regarding issue with minifying the variable , i was actually not aware of those .
    Sencha Touch Demos

    IosToggleField Forum - Github
    Form Validation
    Forum - Github
    Iphone Settings Menu
    Forum
    Sqlite Storage & Login Manifest
    Forum
    KitchenSink MVC
    Forum - Github
    SqliteProxy-v1 Forum - Github
    SqliteProxy-v2
    Forum - Github
    Arshaw Fullcalendar Forum - Github






  4. #14
    Sencha User tomalex0's Avatar
    Join Date
    Apr 2009
    Location
    San Jose, CA
    Posts
    589
    Vote Rating
    16
    tomalex0 will become famous soon enough

      0  

    Default


    @salva

    i think record.get(primarykey) , will be better option. I will update my github.

    and also get rid of those eval implementation .
    Sencha Touch Demos

    IosToggleField Forum - Github
    Form Validation
    Forum - Github
    Iphone Settings Menu
    Forum
    Sqlite Storage & Login Manifest
    Forum
    KitchenSink MVC
    Forum - Github
    SqliteProxy-v1 Forum - Github
    SqliteProxy-v2
    Forum - Github
    Arshaw Fullcalendar Forum - Github






  5. #15
    Sencha User
    Join Date
    Jul 2011
    Posts
    8
    Vote Rating
    0
    ultimate5289 is on a distinguished road

      0  

    Default


    @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:
    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);
    }
    Sorry i have just jumped into Sencha Touch and so confuse on make a custom proxy with sencha touch.

  6. #16
    Sencha User tomalex0's Avatar
    Join Date
    Apr 2009
    Location
    San Jose, CA
    Posts
    589
    Vote Rating
    16
    tomalex0 will become famous soon enough

      0  

    Default


    Try this
    Db Connection
    Code:
    var dbconnval = {
    			dbName: "SpotLife_Spot",
    			dbDescription: "Spot Database"
    		};
    
    
    		Ext.DbConnection = new Ext.Sqlite.Connection(dbconnval);
    Table Model which creates Table
    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'
    		});
    Sencha Touch Demos

    IosToggleField Forum - Github
    Form Validation
    Forum - Github
    Iphone Settings Menu
    Forum
    Sqlite Storage & Login Manifest
    Forum
    KitchenSink MVC
    Forum - Github
    SqliteProxy-v1 Forum - Github
    SqliteProxy-v2
    Forum - Github
    Arshaw Fullcalendar Forum - Github






  7. #17
    Sencha User tomalex0's Avatar
    Join Date
    Apr 2009
    Location
    San Jose, CA
    Posts
    589
    Vote Rating
    16
    tomalex0 will become famous soon enough

      0  

    Default


    If you are checking in Chrome try this in sqlite console.
    Code:
    SELECT sql FROM sqlite_master WHERE type='table' and name='CAPTUREDSPOT';
    Sencha Touch Demos

    IosToggleField Forum - Github
    Form Validation
    Forum - Github
    Iphone Settings Menu
    Forum
    Sqlite Storage & Login Manifest
    Forum
    KitchenSink MVC
    Forum - Github
    SqliteProxy-v1 Forum - Github
    SqliteProxy-v2
    Forum - Github
    Arshaw Fullcalendar Forum - Github






  8. #18
    Sencha User
    Join Date
    Jul 2011
    Posts
    8
    Vote Rating
    0
    ultimate5289 is on a distinguished road

      0  

    Default


    Thank for your support . I just don't understand why you override destroy on model and when the destroy function on proxy work .
    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);
                            }
    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 .

  9. #19
    Sencha User tomalex0's Avatar
    Join Date
    Apr 2009
    Location
    San Jose, CA
    Posts
    589
    Vote Rating
    16
    tomalex0 will become famous soon enough

      0  

    Default


    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 .
    Sencha Touch Demos

    IosToggleField Forum - Github
    Form Validation
    Forum - Github
    Iphone Settings Menu
    Forum
    Sqlite Storage & Login Manifest
    Forum
    KitchenSink MVC
    Forum - Github
    SqliteProxy-v1 Forum - Github
    SqliteProxy-v2
    Forum - Github
    Arshaw Fullcalendar Forum - Github






  10. #20
    Sencha User bastard's Avatar
    Join Date
    Aug 2011
    Location
    I'm in Cali baby!
    Posts
    65
    Vote Rating
    4
    bastard is on a distinguished road

      0  

    Default 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,
    		});
    	}
    });