Page 3 of 3

What if I don't want to use online database?

Posted: Tue Jun 10, 2014 2:37 pm
by Evgene Karachevtsev

Hello Dave,

You can create value object:

code var value = {_id:1,
number:1,
RxName: "name",
Dose : 1,
Freq_Num : 1,
Freq_Per : 1,
RxNum : 1,
Pharmacy : "sss",
PharmNum: 1,
Notes : "sss",
StoreNum: 1,
_createdAt : "01.01.2014",
_updatedAt : "01.01.2014"
} ;/code

and delete return in file "MedDB_LocRestJS.js"


What if I don't want to use online database?

Posted: Tue Jun 10, 2014 3:51 pm
by Dave Troxel

Hi Evgene,
I inserted the above and am getting some unexpected extra lines in local storage.. Please help me.

Image

My script is now as follows:

Appery.MedDB_LocRestJS = Appery.createClass(null, {

Code: Select all

 init : function(requestOptions) { 
     this.__requestOptions = $.extend({}, requestOptions); 
 }, 

 process : function(settings) { 
     this.settings = settings; 
     settings.beforeSend(settings); 
     if (this.__requestOptions.echo) { 
         settings.success(this.__requestOptions.echo); 
     } else { 
         console.log('Default implementation is used. Please define your own.'); 
         settings.success({}); 
     } 
     settings.complete('success'); 
 } 

});

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

var value = {_id:1,
number:1,
RxName: "name",
Dose : 1,
Freq_Num : 1,
Freq_Per : 1,
RxNum : 1,
Pharmacy : "sss",
PharmNum: 1,
Notes : "sss",
StoreNum: 1,
_createdAt : "01.01.2014",
_updatedAt : "01.01.2014"
} ;

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){
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]);
}
);
});


What if I don't want to use online database?

Posted: Wed Jun 11, 2014 4:02 pm
by Maryna Brodina

Hello Dave!

I am sorry to have to tell you, but building app with offline DB fails outside the scope of our support. We have posted a lot of suggestions, but building app, reviewing/debugging custom app code/scripts are outside the scope of support.
You can contact Appery.io services team http://appery.io/services/ so they can take a closer look at your problem.