File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -76,7 +76,8 @@ query.withCount();
7676const response = await query .find (); // { results: [ GameScore, ... ], count: 200 }
7777```
7878⚠️ Сount operations can be slow and expensive.
79- > If you only want to get the count without objects - use [ Counting Objects] ( #counting-objects ) .
79+
80+ If you only want to get the count without objects - use [ Counting Objects] ( #counting-objects ) .
8081
8182For sortable types like numbers and strings, you can control the order in which results are returned:
8283
Original file line number Diff line number Diff line change @@ -63,6 +63,32 @@ You can skip the first results by setting `skip`. In the old Parse hosted backen
6363$query->skip(10); // skip the first 10 results
6464```
6565
66+ ### With Count
67+
68+ If you want to know the total number of rows in a table satisfying your query, for e.g. pagination purposes - you can use ` withCount ` .
69+
70+ ** Note:** Using this feature will change the structure of response, see the example below.
71+
72+ Let's say you have 200 rows in a table called ` GameScore ` :
73+
74+ ``` php
75+ $query = new ParseQuery('GameScore');
76+ $query->withCount();
77+ $query->limit(25);
78+
79+ $response = $query->find();
80+ $response['count'] // Returns 200 the total number of objects dispite limit / skip
81+ $response['results'] // Returns 25 objects
82+
83+ // As of PHP 7.1 you can use Array Destructuring
84+ ['count' => $count, 'results' => $results] = $query->find();
85+
86+ // Use $count and $results
87+ ```
88+ ⚠️ Сount operations can be slow and expensive.
89+
90+ If you only want to get the count without objects - use [ Counting Objects] ( #counting-objects ) .
91+
6692### Ascending and Descending
6793
6894For sortable types like numbers and strings, you can control the order in which results are returned:
You can’t perform that action at this time.
0 commit comments