Thanks in advance.
Hi Max,
thanks but newish to this..
I've put javascript of
var count = data.allSaved.length;
console.log(count);
localStorage.setItem('total', count);
as event on query success, where allSaved is the name of the response parameter:
$allSaved
-userId
-name
etc..
but console gives warning of
Uncaught TypeError: Cannot read property 'length' of undefined
what is the correct syntax here? Thanks
Hi Charles, we have a tutorial that describes approach how to work with objects in the collection, it can help to understand :: http://docs.appery.io/tutorials/build...
Hi Illya, thanks again, looked at that but how would I count the objects that I've already returned using a query service with 'where' and 'sort' parameters - needs to be dynamic as service will return different number of objects based on request?
Can I add a 'count' request parameter to the query like I've already added 'limit' and 'skip'? If so, how would I get the response from that?
Or could I use JS on success event as I've written above? I suspect this is the way but not sure of syntax and how to capture this..
Hi Charles,
You can add one more Request parameter "count" that returns a number of elements. You should do this in separate service and call separately. Or you can count mapped items manually:prevar myCount = localStorage.getItem("myCount");
localStorage.setItem("myCount",myCount++);/preAdd this code to an array item mapping.
Thanks for your help - in the end I just put a show more button that skipped through the rows of filtered query objects.
I have created 2 service, one with paratmeter count = 0, another count = 1, but both service return count only, how can I have one service return array of database items, another specifically return number of rows only?
Hi,
It's better to remove the code added before. Then on service Success event run this JavaScript code: prevar count = data.length;/preWhere 'count' is a number of response elements.
Another service will return data. If these services use the same parameters then you can add this code to one of them and call it.
If we have implemented pagination and added this code then doesnt this return the limit value and not the total records in query ?