Is it possible to synchronize data from cordova-sqlite?
I have a caseTable table with fields (ID, caseName, date). Each row in this table corresponds to another table named in the caseName field. I need to go through the caseTable table and get the number of rows in the table.
function onDeviceReady() { db = window.openDatabase("Casepad", "1.0", "Casepad", 200000); db.transaction(getallTableData, errorCB); } function insertData() { db.transaction(createTable, errorCB, afterSuccessTableCreation); } // create table and insert some record function createTable(tx) { tx.executeSql('CREATE TABLE IF NOT EXISTS CaseTable (id INTEGER PRIMARY KEY AUTOINCREMENT, CaseName TEXT unique NOT NULL ,CaseDate INTEGER ,TextArea TEXT NOT NULL)'); tx.executeSql('INSERT OR IGNORE INTO CaseTable(CaseName,CaseDate,TextArea) VALUES ("' + $('.caseName_h').val() + '", "' + $('.caseDate_h').val() + '","' + $('.caseTextArea_h').val() + '")'); } // function will be called when an error occurred function errorCB(err) { navigator.notification.alert("Error processing SQL: " + err.code); } // function will be called when process succeed function afterSuccessTableCreation() { console.log("success!"); db.transaction(getallTableData, errorCB); } // select all from SoccerPlayer function getallTableData(tx) { tx.executeSql('SELECT * FROM CaseTable', [], querySuccess, errorCB); } function querySuccess(tx, result) { var len = result.rows.length; var t; $('#folderData').empty(); for (var i = 0; i < len; i++) { /* ************************************************************* * Here i need to call a synchronous method which returns the * number of rows in the result.rows.item(i).CaseName table * ************************************************************* */ $('#folderData').append( '<li class="caseRowClick" id="' + result.rows.item(i).id + '" data-rel="popup" data-position-to="window">' + '<a href="#">' + '<img src="img/Blue-Folder.png">' + '<h2>' + result.rows.item(i).CaseName + t+'</h2>' + '<p>' + result.rows.item(i).TextArea + '</p>' + '<p>' + result.rows.item(i).CaseDate + '</p>' + '<span class="ui-li-count">' + i + '</span></a>' + '<span class="ctrl togg"><fieldset data-role="controlgroup" data-type="horizontal" data-mini="true" ><button class="edit button_design">Edit</button><button class="del button_design">Delete</button></fieldset><span>'+'</li>' ); } $('#folderData').listview('refresh'); }
The sign of displaying the value of "i" in the list view, I need to show how many elements in this table. I need to call synchronization because I need to call some query that counts the number of elements in "result.rows.item (i) .CaseName" in this element ..?
Take an example ...
Case Pad Database Name CaseTable Table Name
Let assume having entries in caseTable. ID CaseName Case Date caseNote 1 Test 3/77/13 jgjgj 2 Test2 4/34/3 hsadkkadsh Now I have two more table in DB Test , Test2.. **Test** having entries like this ID DocumentName Date Notes 1) ppp 7/33 asdhdfkdshf 2) asdjhad 9/44 dfjasgfsjfj **Test2** having entries like this ID DocumentName Date Notes 1) sad 7/4 asdhdfkdshf 2) assd 3/44 hhhhhh 3) asd 2/22 adgjad
Now Test, Test2 have a record of 2 and 3.
Now I need to get data from CaseTable. If you want, I need to count the number of elements in my casename table (Test, Test1). here only
function getallTableData(tx) { tx.executeSql('SELECT * FROM CaseTable', [], querySuccess, errorCB); } function querySuccess(tx, result) { var len = result.rows.length; var t; $('#folderData').empty(); for (var i = 0; i < len; i++) { Here i need to call synchronize method which call the number of element in in that result.rows.item(i).CaseName and insert it in this table **************************************************************************** $('#folderData').append( '<li class="caseRowClick" id="' + result.rows.item(i).id + '" data-rel="popup" data-position-to="window">' + '<a href="#">' + '<img src="img/Blue-Folder.png">' + '<h2>' + result.rows.item(i).CaseName + t+'</h2>' + '<p>' + result.rows.item(i).TextArea + '</p>' + '<p>' + result.rows.item(i).CaseDate + '</p>' + '<span class="ui-li-count">' + i + '</span></a>' + '<span class="ctrl togg"><fieldset data-role="controlgroup" data-type="horizontal" data-mini="true" ><button class="edit button_design">Edit</button><button class="del button_design">Delete</button></fieldset><span>'+'</li>' ); } $('#folderData').listview('refresh'); }
I need to print case case caseate case Note the number of elements So my list looks like this:
Test 3/77/13 jgjgj 2 Test2 4/34/3 hsadkkadsh 3
How to print 2 and 3 in this table ... :( can you answer any question)