Page 1 of 1

REST Database/cURL in Appery

Posted: Sun Nov 03, 2013 9:48 pm
by Branden

I need to access the Appery database through some elements that are not built in to the Appery UI.

For example, I have a list of dynamically generated fields. I'm capturing the values of those fields to an array. I want to store that array in the database.

Because the fields are dynamically generated, they are not seen as "components" in Appery, and therefore do not seem to appear in the Data tab of the UI. So it looks like I need to do this manually, which is fine. Unfortunately, all of the Appery documentation regarding the database involves the use of cURL. That's fine if you're on a command line, but not particularly useful if you're running it from a mobile app.

My question: I have dynamically generated fields who values I can capture into an array. How do I submit that to the database using REST calls manually? Better yet, is there a way to "force" Appery to take my generated items and convert them into components?

Thank you very much!


REST Database/cURL in Appery

Posted: Sun Nov 03, 2013 9:55 pm
by maxkatz

If you generate the UI components, save their values (user submitted) into local storage, then simply map from local storage to a service that saves into Appery.io database. Check out the tutorial, they show how to automatically create services for working with Appery.io database.

http://docs.appery.io/tutorials


REST Database/cURL in Appery

Posted: Sun Nov 03, 2013 10:00 pm
by Branden

Max,

Code: Select all

Thank you very much for your reply. I was hoping to avoid using local storage in this case, but if that's the best way then that's how I'll do it. 
Regarding your link... I was already there but I couldn't find the specific tutorial for automatically creating services. Can you provide me with the specific tutorial? 
Thanks! 

P.S. I'm very new to Appery. So far, however, I'm very pleased both with the service and support. Thanks!


REST Database/cURL in Appery

Posted: Sun Nov 03, 2013 10:10 pm
by maxkatz

Under Start Here: http://docs.appery.io/tutorials/. It will show you how to generate the services.


REST Database/cURL in Appery

Posted: Sun Nov 03, 2013 11:52 pm
by Branden

Thank you for the link.
I just realized, however, why I can't use local storage to work in between the app and the database.

With each field, I'm actually capturing two values: the value of a slider and the name/text of the label. The name/value are associated with each other.

I also have a variable number of fields from which I want to capture these values. I'm not sure how to accomplish that with localstorage since that only seems to work with a single key/value pair. That's why I was hoping to go straight to the database...


REST Database/cURL in Appery

Posted: Mon Nov 04, 2013 3:42 am
by maxkatz

If all the components are added to the page in runtime, you would need to iterate over all the components you generated in JavaScript, read their values and save them in local storage. Once the values are in local storage, you could map them to the service.


REST Database/cURL in Appery

Posted: Mon Nov 04, 2013 1:14 pm
by Branden

But if localstorage is limited to a single key/pair mapping, how can I associate two values (label text and and slider value) with a single key?


REST Database/cURL in Appery

Posted: Mon Nov 04, 2013 4:07 pm
by maxkatz

The value could be a JSON object that holds two or more values.