File tree 2 files changed +28
-1
lines changed
2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -76,7 +76,8 @@ query.withCount();
76
76
const response = await query .find (); // { results: [ GameScore, ... ], count: 200 }
77
77
```
78
78
⚠️ С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 ) .
80
81
81
82
For sortable types like numbers and strings, you can control the order in which results are returned:
82
83
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
63
63
$query->skip(10); // skip the first 10 results
64
64
```
65
65
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
+
66
92
### Ascending and Descending
67
93
68
94
For 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