Page 1 of 1

Accesing the return dataset of a query

Posted: Tue Jun 09, 2015 2:10 am
by sdanigo

Hi,
I'm still a newbie here :-)
When we perform a query on a database, what is the correct syntax in JS to access the returned data.
Example, I query some customer from a mySql database, it is supposed to return the custId and the custName. I would like to
-1- store the whole return dataset in a local storage variable so I can use it later, even if offline.
-2- perform some task on the returned fields (add some extra information depending of the value of the content for example)

If someone could help me, it would be greatly appreciated.

Thanks

Sylvain


Accesing the return dataset of a query

Posted: Tue Jun 09, 2015 12:04 pm
by Serhii Kulibaba

Hello,

Could you clarify what have you tried and what exactly does not work? You can save whole service's response on its success event.


Accesing the return dataset of a query

Posted: Tue Jun 09, 2015 12:36 pm
by sdanigo

Hi
I use a rest service. It is returning 3 fields:
custId,custFirstname and custLastName.
I know how to map them to screen components.. My question are:
What is the correct JS syntax to save the whole response on a localstorage variable in the succes event of the service ?
What is the correct JS syntax to access for example each custFirstname and custLastname in order for example to create a computed field on each record.

Thanks

Sylvain


Accesing the return dataset of a query

Posted: Wed Jun 10, 2015 1:11 pm
by Serhii Kulibaba

You can get whole response on success event in data variable.
So you can get each element with loop:

for(var i = 0; i < data.length; i++){
console.log(data.custFirstname);
}


Accesing the return dataset of a query

Posted: Wed Jun 10, 2015 1:24 pm
by sdanigo

Thank you