Christopher Herold
Posts: 0
Joined: Fri Jun 28, 2013 8:27 pm

Saving a database list into a local variable.

Greetings,

Could you please advise me on how to download the ENTIRE contents of one of my database tables into a local variable?

right now when I am doing it using the database list query, the local variable is only holding the last value read from the database.

Thank you!
Chris

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

Saving a database list into a local variable.

Do a GET on the entire database, you then would need to run JavaScript to save all the data into local storage into one variable or multiple variables -- that's up to the app logic. Do keep in mind that local storage has a max. size of about 5Mb.

Christopher Herold
Posts: 0
Joined: Fri Jun 28, 2013 8:27 pm

Saving a database list into a local variable.

I could really use some more directed assistance with this, if you have the time.

I perhaps should have specified that I want to pull down a list of database contents based on a where statement, not the entire contents.

(1) How do I do it with a GET? All I see for database services that seems relevant are Query and List services.

(2) Then how do I manipulate this data with javascript to put the data into one variable?

More structured help would be appreciated. I am not a veteran at this type of programming.

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

Saving a database list into a local variable.

These tutorials will show you how to do a query service:
http://docs.appery.io/tutorials/build...
http://docs.appery.io/tutorials/build...

and this is the user guide for all queries: http://docs.appery.io/documentation/b...

Here is how to save the response into local storage: http://docs.appery.io/documentation/u...

You can also always use the 'success' callback to get the data returned from the service and do anything you need with it.

Christopher Herold
Posts: 0
Joined: Fri Jun 28, 2013 8:27 pm

Saving a database list into a local variable.

Ok, I was able to use that to get the json_reponse data and put it into a local variable and then call it as needed. Thank you for the guidance.

Next step: I need to pull specific columns for each row of the database and then format the retrieved data for presentation.

Where can I specify what data columns I want to get as part of the json_reponse?

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

Saving a database list into a local variable.

We don't yet have an option to specify to get only specific columns via a REST API. You get all the columns but can display only the once you need.

The only other alternative is to use Server Code, where you would first get all the data and then return only the columns (data) that you want. This approach would require coding in JavaScript.

Christopher Herold
Posts: 0
Joined: Fri Jun 28, 2013 8:27 pm

Saving a database list into a local variable.

How would I go about this using Server Code? I don't know where to start. Are there any examples?

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

Saving a database list into a local variable.

There is also a new beginners tutorial here: http://docs.appery.io/tutorials/.

Christopher Herold
Posts: 0
Joined: Fri Jun 28, 2013 8:27 pm

Saving a database list into a local variable.

Without some additional guidance that is unlikely to be a viable solution given my background. Are you able to provide additional guidance?

Return to “Issues”