Gilbert Gomez
Posts: 0
Joined: Sat Sep 07, 2013 2:35 am

Help me get this straight: arrays in database

Hi Marina, how are you?

I was reading topics related to arrays troubles but ...well I am not an expert programer ..so I do not how to use it ..but I still have this trouble.

I leave you my app schema to explain what I have done

Image

My intention was to get a page (from a database) to navigate ...read by a RestService with a "where" parameter as condition to get just those rows with a certain value on its column2. and then mapped with one Datasource to my "MobileList1" control and local storage variable ...here also you can see the javaScript used on click events.

Have a nice day
Thanks

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

Help me get this straight: arrays in database

Hello! I'll update original post when have more information https://getsatisfaction.com/apperyio/...

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

Help me get this straight: arrays in database

The link provided by Katya no longer works. Is there an updated link? Thanks!

pakbull6772540
Posts: 0
Joined: Sun Mar 30, 2014 4:08 pm

Help me get this straight: arrays in database

I am stumped at this point and need some simple directions to store a localStorage array in the database that has a column type array. I have tried all variations and it keeps on giving me the same error:

code: "DBSC252"
description: "Invalid value for type 'array': '[{"x":"startScreen_chk_panelIntenet"}]'."

In the Javascript I am using JSON.strigify like below examples. Multiple variations all failing to enter data in the database. What is worse is that when I use the editor's create service to test the load using the values, it always works. Just not thru the mapping.

the javascripts I have tried are:

var chkID = [];
Appery(chkgrpName).find("input:checked").each(function() {
chkID.push($(this).attr("id"));
});

localStorage.setItem('locVal', JSON.stringify(chkID));

This would have been the simplest as it returns an array thru JSON that looks like:
["startScreen_chk_panelIntenet"] but that does not work.

I then used string functions to add {} around the string but that does not work.

I tried the above but those examples are for extraction / query. I need to upload to the database.

Thank you

Igor
Posts: 0
Joined: Tue Apr 02, 2013 12:05 pm

Help me get this straight: arrays in database

Hello,

To update array db field with update service you need to:

1 Click "Edit mappings" to update datasource.

2 Navigate to "Request" datasource tab.

3 Find your array field. For example it's "friends" field.

4 Click on the "Edit JS" or "Add JS" for this field. See details here:

Image

5 javascript editor appears. Populate it with following code:

pre
return ["firstElement","secondElement"];
/pre
So as you see in code above you have to return array of JS object(not a string).

If you want to get this array from your localstorage variable you need to use following code:

pre
var arrayToReturn = JSON.parse(localStorage.getItem("'locVal'"));
return arrayToReturn;
/pre

Return to “Issues”