How can I count the number of an especific value in DB on the app and then show it in the UI?

This forum contains topics that were moved from Get Satisfaction
Miguel Carrillo
Posts: 0
Joined: Mon Sep 29, 2014 7:46 pm

How can I count the number of an especific value in DB on the app and then show it in the UI?

Post by Miguel Carrillo »

How can I count specific values from a DB to show them in the app? I need to check in my DB if some value is 'yes' or 'not' and them show in the app the total number of values that are equals to yes and the ones that are not.

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

How can I count the number of an especific value in DB on the app and then show it in the UI?

Post by Yurii Orishchuk »

Hi Miguel,

You can use this this goal "list/query" service with certain "where" and "count" parameters.

See details about "where" parameter:
http://devcenter.appery.io/documentat...

See details about "count" parameter:
http://devcenter.appery.io/documentat...

Regards.

Russ Biggers
Posts: 0
Joined: Sun Aug 10, 2014 10:19 pm

How can I count the number of an especific value in DB on the app and then show it in the UI?

Post by Russ Biggers »

(I have the same question)

I understand that you can use these parameters but how do you return the count to a local storage variable or to a label so that it can be used in the app?

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

How can I count the number of an especific value in DB on the app and then show it in the UI?

Post by Kateryna Grynko »

Hi Russ,

When creating a mapping, you should specify where to save a result.

You can either save it in a component (in your case it is a label), or in a local storage variable (then you should create this variable in 'model and storage' section beforehand).

Russ Biggers
Posts: 0
Joined: Sun Aug 10, 2014 10:19 pm

How can I count the number of an especific value in DB on the app and then show it in the UI?

Post by Russ Biggers »

I have tried to specify where to save the result but I can not seem to find where to do that. I have uploaded pictures. The first one is of the before send on the query where I can specify the count. The second one is the mapping of the success but there is not an option to map the count to anything. Image Image

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

How can I count the number of an especific value in DB on the app and then show it in the UI?

Post by Yurii Orishchuk »

Hi Russ,

To get count of returned service items you can:

1 Add "Success" event handler for service.

2 Populate it with following code:

pre

//Get items count.
var count = data[0].count;

//Save count to LSV.
localStorage.setItem("lsvName", count);

/pre

After you can get "lsvName" lsv where you need with following code:

pre

var count = localStorage.setItem("lsvName", count);

alert(count);

/pre

Regards

Russ Biggers
Posts: 0
Joined: Sun Aug 10, 2014 10:19 pm

How can I count the number of an especific value in DB on the app and then show it in the UI?

Post by Russ Biggers »

I tried doing what you have suggested but for some reason when I add the count parameter my queries stop working. It messes up all of my other queries that were previously working. Once I remove the count parameter the other queries begin to work again.

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

How can I count the number of an especific value in DB on the app and then show it in the UI?

Post by Yurii Orishchuk »

Hi Russ,

"Count" service should be implemented as separate service.

So:
1 Delete "count" parameter from the service.
2 Duplicate this service. http://prntscr.com/4xukgb/direct
3 Rename new(clone) service as you need.
4 Open this service and add "count" parameter.
5 Use this new service where you need to get count.
6 Use old service where you need to get list.

Regards.

Post Reply