Hawk
Posts: 0
Joined: Mon Aug 04, 2014 11:23 am

Reading multiple DB records into storage model

Ok. Is their a way to the values of these objects? My initial question is how to read multiple records into local storage? For example the screenshots above show my collection column. I need to read each eecord to a local array. Isnt that possible?

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Reading multiple DB records into storage model

Hawk,

You turned out? "bonus" will be an array of all the values of MPD_Month.

Hawk
Posts: 0
Joined: Mon Aug 04, 2014 11:23 am

Reading multiple DB records into storage model

Hi Evgene,

I'm still getting the error: Mapping expression is incorrect. Note that the model and storage names have been updated to (Member_Points_Details_Array) as in the second post in this thread. Is the mapping correct?

Hawk
Posts: 0
Joined: Mon Aug 04, 2014 11:23 am

Reading multiple DB records into storage model

In order to reporoduce the problem:

link: http://appery.io/app/mobile-frame?src...

credentials: 1234/star1234

Navigation: NavBar My Points On page load the service (Member_Points_Details_Array) will be invoked (Screenshot of the service mapping shown in the second post in this thread) click on the button highlighted below and a panel will appear

Image

When you click on any month, the number that should be passed to i will appear in alert. (e.g. when you click on June 2014, alert will show 6).

The code that should brings data from Member_Points_Details_Array is called on mobileradiogroup value change.

Apart from the long code only the main point need to be resolve. That is in this code when I select June 2014 and hence i = 6, the the following code:

prevar bonus = Apperyio.storage.MS_Member_Points_Details_Array.get("$['MPD_Month']");
console.log(bonus);/pre

should show the value of bonus of that month in consolde. Similarly, if I click on Jan 2014, the value of bonus of January should appear in the console.

In short, I expect the mapping to pass the values of the all column for that specific users and for all months into Member_Points_Details_Array

Many thanks for your help

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Reading multiple DB records into storage model

Hi Hawk,

.get() function - returns object. Then you should navigate through this object with JS syntax.

Here is correct code for you:

pre

var bonus = Apperyio.storage.MS_Member_Points_Details_Array.get().MPD_Month;

/pre

Regards.

Hawk
Posts: 0
Joined: Mon Aug 04, 2014 11:23 am

Reading multiple DB records into storage model

Hi Yurri,

I used this code and when I choose (Aug 2014) which mean i = 8, I got the error:

preUncaught TypeError: Cannot read property '8' of undefined /pre

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Reading multiple DB records into storage model

Hi Hawk,

That means you have not object inside your "MS_Member_Points_Details_Array" storage with index "8" - only that.

Here is code with protection:

pre

var goalArray = Apperyio.storage.MS_Member_Points_Details_Array.get();

var bonus = "No object";

if(goalArray && goalArray && goalArray.MPD_Month)
bonus = goalArray.MPD_Month;

/pre

Regards.

Hawk
Posts: 0
Joined: Mon Aug 04, 2014 11:23 am

Reading multiple DB records into storage model

Thanks Yurii, this works

Hawk
Posts: 0
Joined: Mon Aug 04, 2014 11:23 am

Reading multiple DB records into storage model

Hi,

How can I set value a variable that is part of the storage model. I tried to refer to this tutorial (http://devcenter.appery.io/documentat...) but it did not help.

Basically, I have the storage model "MS_Outlet_Details" that has the variable "UserName". I can read the value of this variable using:

prevar UserName = Apperyio.storage.MS_Outlet_Details.get("$['UserName']");/pre

However, the following did not help to update the value of this variable:

preApperyio.storage.MS_Outlet_Details.set("$['UserName']",UserName); /pre

How can I update it?

Many thank,

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

Reading multiple DB records into storage model

Hawk,

Please take a look here http://devcenter.appery.io/documentat...
set(value) method.

Return to “Issues”