Jahmarley
Posts: 0
Joined: Mon Apr 16, 2012 8:21 pm

sqlite - offline capabilities help

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.

Image

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.

Image

Can you please direct me as to how I will get the table created and populated with the data from parse.com?

Thank you

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

sqlite - offline capabilities help

Hi -

Have you tested the response from the service?

Can you show the service settings and request/response parameters?

Jahmarley
Posts: 0
Joined: Mon Apr 16, 2012 8:21 pm

sqlite - offline capabilities help

Hi Illya,

Thank you for your response. Please see following screen shots.

Image

Image

Image

Image

Thank you for assisting

Jahmarley
Posts: 0
Joined: Mon Apr 16, 2012 8:21 pm

sqlite - offline capabilities help

I just noticed the following error in the chrome developer tools which may be contributing to my issue... can you assit further please...

Image

Image

Thnx

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

sqlite - offline capabilities help

Hello! As we can see from the last screenshot results variable is not defined here (it's defined in nested function). Just delete preresults; /pre from mapping.

Jahmarley
Posts: 0
Joined: Mon Apr 16, 2012 8:21 pm

sqlite - offline capabilities help

Ty for responding Maryna.

I have deleted results; and that error has been fixed.
I am still unable to create the table and populate it with the data from parse.com back end and developer tools show the following:

Image

Image

Image

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

sqlite - offline capabilities help

All response parameters are case sensitive. On screenshot there is Number parameter, but in code value.number (should be value.Number). Please also check other parameters.

Tiago Martins
Posts: 0
Joined: Fri Sep 05, 2014 12:41 am

sqlite - offline capabilities help

Hi,

It's possible to replicate the mapped "anu_biz_inputgrid_service1" (on the first screen") with the new platform?

I have a similiar mapping to a js function to update one local table/database? how can I replicate this in the new platform? I think the new platform doesn't provide mapping element to js.

Image

Thx for you help.

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

sqlite - offline capabilities help

Hi Tiago,

There is several ways to do with new platform:

  1. (in case if you have any link from your "$" response). You can click on JS for link from $. And put here needed code.
    Details: http://prntscr.com/6twf7e/direct

  2. If you have not link from this "$" response you can:
    2.1. Open "Storage and models".

    2.2. Add new model with type "Array". http://prntscr.com/4uey7v/direct

    2.3. Add storage with type model from 2nd step. http://prntscr.com/4ueyq8/direct

    2.4. Navigate to "success" mapping.

    2.5. Make link from "$" to storage from 3rd step: http://prntscr.com/4ueyzi/direct

    2.6. This time you can click on "JS" for link from 5th step and add goal JS code you need. And this code will execute every item from response.

    Regards

Return to “Issues”