Page 1 of 1

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

Posted: Mon Sep 29, 2014 7:46 pm
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.


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

Posted: Tue Sep 30, 2014 2:52 am
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.


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

Posted: Thu Oct 16, 2014 2:13 am
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?


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

Posted: Thu Oct 16, 2014 9:03 am
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).


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

Posted: Thu Oct 16, 2014 3:08 pm
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


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

Posted: Thu Oct 16, 2014 11:49 pm
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


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

Posted: Fri Oct 17, 2014 3:59 pm
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.


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

Posted: Sun Oct 19, 2014 11:53 pm
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.