Page 2 of 2

Help me get this straight: arrays in database

Posted: Mon Sep 16, 2013 6:45 pm
by Gilbert Gomez

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


Help me get this straight: arrays in database

Posted: Mon Sep 16, 2013 6:47 pm
by Maryna Brodina

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


Help me get this straight: arrays in database

Posted: Thu Nov 07, 2013 1:25 pm
by Branden

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


Help me get this straight: arrays in database

Posted: Thu Nov 07, 2013 1:30 pm
by Maryna Brodina

Help me get this straight: arrays in database

Posted: Tue Apr 01, 2014 3:20 pm
by pakbull6772540

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


Help me get this straight: arrays in database

Posted: Wed Apr 02, 2014 1:46 am
by Igor

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