Page 1 of 2

offline DB showing partial. Hopeful now to get other collection/table to show.

Posted: Wed May 21, 2014 2:56 pm
by Dave Troxel

My js script to 'listTables' is working on the first collection(table) but not on the second.
Here is the script and screen shots. Please advise how I get 'DocsColl' table to populate.

var db = window.openDatabase("Meds_DB", "", "Meds_DB", 1024*1000);

db.transaction(function (tx) {
tx.executeSql('CREATE TABLE IF NOT EXISTS "MedsColl"(_objectId TEXT, RxName TEXT, Dose TEXT, Freq_Num TEXT, Freq_Per TEXT, RxNum TEXT, Pharmacy TEXT, PharmNum TEXT, Notes TEXT, StoreNum TEXT, _createdAt DATETIME, updatedAt DATETIME)', []);
tx.executeSql('SELECT * FROM "MedsColl" WHERE "objectId" = "' + value.id + '"', [], function(tx, results){
console.log('rows :' + results.rows.length);
if (results.rows.length == 0){
console.log('Go and add table ' + value.number);
tx.executeSql('INSERT INTO "MedsColl" (objectId, RxName, Dose, Freq_Num, Freq_Per, RxNum, Pharmacy, PharmNum, Notes, StoreNum, _createdAt, updatedAt) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', [value.id, value.RxName, value.Dose, value.Freq_Num, value.Freq_Per, value.RxNum, value.Pharmacy, value.PharmNum, value.Notes, value.StoreNum, value.createdAt, value.updatedAt]);
}
});
});

return;

Image

Image


offline DB showing partial. Hopeful now to get other collection/table to show.

Posted: Wed May 21, 2014 3:11 pm
by Dave Troxel

STOP THE PRESSES.. I did not scoll down the table in this screenshot to see that in fact the two rows that were created in the db ARE There. Success on both sides although not sure why I got so many rows of undefined. They do not show up in the db collection at all. Only the two rows I actually created.

Now I have to figure out how to get it to create the offline database in my mobile device. Do I start with the todo list script?

http://devcenter.appery.io/tutorials/...


offline DB showing partial. Hopeful now to get other collection/table to show.

Posted: Wed May 21, 2014 3:43 pm
by Kateryna Grynko

Hi Dave,

Do you use the same code for both MedsColl and DocsColl? You simply change one line, ad the code doesn't work, right?


offline DB showing partial. Hopeful now to get other collection/table to show.

Posted: Wed May 21, 2014 6:06 pm
by Dave Troxel

I did not include DocsColl in the script at all. But after all the undefined rows, I do see that my data actually populated.
WHere do I inject DocsColl into the script?


offline DB showing partial. Hopeful now to get other collection/table to show.

Posted: Wed May 21, 2014 7:18 pm
by Dave Troxel

Katya, Still not able to run as an offline app. DB will not generate in offline mode. What am I missing? Can you please look at my app? I have sent an invite to Max Katz as well. Here's the link...
http://medi-list2s3.app.appery.io/


offline DB showing partial. Hopeful now to get other collection/table to show.

Posted: Thu May 22, 2014 8:27 am
by Evgene Karachevtsev

Hello Dave,

Could you please detail what issues do you have and how we could help you. Because we tested your application and saw that the table "MedsColl" was successfully created with normal data.


offline DB showing partial. Hopeful now to get other collection/table to show.

Posted: Thu May 22, 2014 12:59 pm
by Dave Troxel

It will not create the database as an offline application on a live mobile device.
I have both an HTC Desire cellphone and a Google Nexus 7 tablet.

In Dev Console, what does this mean?

DELETE https://api.appery.io/rest/1/db/colle... 404 (Not Found)

Please see app here:

http://medi-list2s5.app.appery.io/


offline DB showing partial. Hopeful now to get other collection/table to show.

Posted: Fri May 23, 2014 6:18 am
by Evgene Karachevtsev

Hello Dave,

Could you please tell why have you decided that you will not create the local database on mobile phone? Have you tested your application? We have just tested local database on android 4.0.3 - it works fine. But local database on android works only if you create apk application.


offline DB showing partial. Hopeful now to get other collection/table to show.

Posted: Sun May 25, 2014 3:45 am
by Dave Troxel

Evgene, I tried exporting my app to an apk for android, loading it on my tablet, but still could not get it to create a local db. Even tried using form within app which adds data(rows) to the appery.io db in the cloud but would not work on the tablet. Please advise how I should proceed.


offline DB showing partial. Hopeful now to get other collection/table to show.

Posted: Mon May 26, 2014 10:45 am
by Evgene Karachevtsev

Dave,

We have run this code for testing local database. And we have viewed console with Weinre: http://devcenter.appery.io/documentat...
code//insert
function populateDB(tx) {
tx.executeSql('DROP TABLE IF EXISTS DEMO');
tx.executeSql('CREATE TABLE IF NOT EXISTS DEMO (id unique, data)');
tx.executeSql('INSERT INTO DEMO (id, data) VALUES (1, "First row")');
tx.executeSql('INSERT INTO DEMO (id, data) VALUES (2, "Second row")');
}

function errorCB(err) {
console.log("Error processing SQL: "+err.code);
}

function successCB() {
console.log("success!");
}

////select
function queryDB(tx) {
tx.executeSql('SELECT * FROM DEMO', [], querySuccess, errorCB);
}

function querySuccess(tx, results) {
console.log("Returned rows = " + results.rows.length);
}

console.log("table DEMO");
var db = window.openDatabase("Database", "1.0", "PhoneGap Demo", 200000);
db.transaction(populateDB, errorCB, successCB);
db.transaction(queryDB, errorCB);
console.log("finish"); /code