Skip to content
This repository has been archived by the owner on Feb 25, 2018. It is now read-only.

getCount is missing Limit = 0 #55

Closed
FredvanRijswijk opened this issue Nov 23, 2012 · 2 comments
Closed

getCount is missing Limit = 0 #55

FredvanRijswijk opened this issue Nov 23, 2012 · 2 comments

Comments

@FredvanRijswijk
Copy link

If you are limiting your query, or if there are a very large number of results, and you want to know how many total results there are without returning them all, you can use the count parameter. For example, if you only care about the number of games played by a particular player:


curl -X GET \
  -H "X-Parse-Application-Id: ucucfdUq3EpDau0cOTPGDl5EKepBYmLlJpNoXKdo" \
  -H "X-Parse-REST-API-Key: sysqIYFSGV6KzCczu1amCs3iTWnukJC8vGu0Li9r" \
  -G \
  --data-urlencode 'where={"playerName":"Jonathan Walsh"}' \
  --data-urlencode 'count=1' \
  --data-urlencode 'limit=0' \
  https://api.parse.com/1/classes/GameScore

Adding a setLimit(0) is not possible, but if you want to make a dashboard it's very slow, because the reason above says it's also getting all the data...

@FredvanRijswijk
Copy link
Author

Solved this woth this code in parseQuery.php

line 45

if($this->_count == 1){
            $urlParams['count'] = '1';
            $urlParams['limit'] = '0';
        }

and

line 59:

public function getCount(){
        $this->_count = 1;
        $this->_limit = 0;
        return $this->find();
    }

@warnew
Copy link
Contributor

warnew commented Jun 3, 2013

You created a a problem, not solved one. Now you have to use two request for counting and displaying results, wasting one.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants