Branden
Posts: 0
Joined: Sun Nov 03, 2013 12:10 am

Arrays of objects in localStorage to database

How do I take an array of objects from localStorage and insert them into the database?

I read these two posts:
https://getsatisfaction.com/apperyio/...
https://getsatisfaction.com/apperyio/...

They're helpful, but I'm having a hard time wrapping my head around it.

In localStorage, I have an array that looks something like this:

[{"name":"Some Name","value":"5"},{"name":"Another Name","value":"23"}, etc...
I'd like to store each name in the database along with their associated value.

Is there a way to do this within the UI tool? As I said, I found a couple similar posts but I'm not sure that's what I'm looking for.

Thank you very much!

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

Arrays of objects in localStorage to database

You would write some JavaScript to read the values from local storage and convert them to a format that you need in your database.

Branden
Posts: 0
Joined: Sun Nov 03, 2013 12:10 am

Arrays of objects in localStorage to database

Thank you for the reply.
I was hoping to do it without too much custom JS. It seems like every page has "special" JS written for it, which is becoming difficult to manage.
I was getting the impression from the other posts that it was possible to do this within the UI tool ...

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

Arrays of objects in localStorage to database

No JavaScript is needed if you have simple string-based values.

Branden
Posts: 0
Joined: Sun Nov 03, 2013 12:10 am

Arrays of objects in localStorage to database

I was able to make some progress by following this post: https://getsatisfaction.com/apperyio/...

I can pull the values from the array in the database and map them to some fields using the UI.

What is NOT working, however, is the loop. There may be several entries in the array, but it only displays the first one. Your tutorials use Lists as examples when looping with the database services. I don't want to use a List, I'd like to use a grid and loop with that. (Each loop will be inputting several different values, which isn't practical with a List).

Can we use a loop with a grid?

Thanks!

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

Arrays of objects in localStorage to database

Hello! I'll check and let you know.

Branden
Posts: 0
Joined: Sun Nov 03, 2013 12:10 am

Arrays of objects in localStorage to database

Thank you. :)

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

Arrays of objects in localStorage to database

Please take a look here http://docs.appery.io/documentation/u... - here is more information how and where you can map arrays.

Branden
Posts: 0
Joined: Sun Nov 03, 2013 12:10 am

Arrays of objects in localStorage to database

This still isn't working like I thought.

At this point, I simply want to take an array of objects in localStorage and update a database column with the new array of objects.

In my old environment (PHP/MySQL), I could do this in 5 minutes. On here, I've been struggling for days.

I understand I have to write Javascript to read from localStorage and convert it to something that the database can read. Unfortunately, I can't seem to get the database to accept the data no matter what I do to it.

In my Update request, I am able to pass the value localStorage to custom Javascript. Yay. I want to take that data... that array of objects... and put it into the database column (type:array).

If you'll forgive my sarcasm for a moment, there doesn't seem to be any Javascript on this planet that can accomplish this successfully. I've tried taking each object as a string, pushing that string to an array... but that didn't work. I tried taking the entire array of objects and converting it to one big string, but that didn't work. I've tried other things too. NOTHING works!

My purpose in trying Appery was to save time and get things done quicker. At first, things were great. But as soon as I had to interface between local storage and the database via REST, everything became a battle.

I've combed through your documents and tutorials. None of them explain how to do what I'm trying to do. I don't think I'm trying to do anything strange or unusual, and that's reinforced the many others on here that have asked similar questions regarding arrays of objects.

Sorry if I sound short, I just really need some assistance here so that I can continue on with my project.

Thank you very much!

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

Arrays of objects in localStorage to database

Hi Branden, can you share your app and your DB with a href="mailto:support@appery.io" rel="nofollow"support@appery.io/a? We'll take a look. :: http://docs.appery.io/documentation/s...

Return to “Issues”