Good day Appery,
I've been following yor tutorial... http://docs.appery.io/tutorials/build... in order to add offline capabilities to my app and i'm using parse.com to store my data.
I edited the code you provided to include my column names... which the tutorials says will open the local database, Creates table if not exist, Checks if element exists in local db and add element with details returned by database service.
This is my edit to the code:
var db = window.openDatabase("Dapp Mobile", "0.1", "Dapp Mobile", 1024*1000);
db.transaction(function (tx) {
tx.executeSql('CREATE TABLE IF NOT EXISTS "antiguabusiness"(_objectId TEXT, Address TEXT, BusinessDetails TEXT, BusinessHours TEXT, BusinessName TEXT, BusinessType TEXT, Country TEXT, Email TEXT, Facebook TEXT, Image TEXT, Location TEXT, Logo TEXT, Number TEXT, Number2 TEXT, Number3 TEXT, Twitter TEXT, Website TEXT, _createdAt DATETIME, updatedAt DATETIME)', []);
tx.executeSql('SELECT * FROM "antiguabusiness" 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 "antiguabusiness" (objectId, BusinessDetails, BusinessHours, BusinessName, BusinessType, Country, Email, Facebook, Image, Location, Logo, Number, Number2, Number3, Twitter, Website, _createdAt, updatedAt) values (?, ?, ?, ?, ?, ?, ?)', [value.id, value.BusinessDetails, value.BusinessHours, value.BusinessName, value.BusinessType, value.Country, value.Email, value.Facebook, value.Image, value.Location, value.Logo, value.Number, value.Number2, value.Number3, value.Twitter, value.Website, value.createdAt, value.updatedAt]);
}
});
});
results;
I have created the service to return the results from parse.com, mapped the response to the above javascript and invoked the service on load event.
However, when checking in google chrome developer tools under resources, I can see that the database has been created 'Dapp Mobile' but the table 'antiguabusiness' is not created and populated.
Can you please direct me as to how I will get the table created and populated with the data from parse.com?
Thank you