Skip to content

Commit 44b8f54

Browse files
Merge pull request #1 from BufferUnderflower/BufferUnderflower-withCount
Documentation for ParseQuery.withCount
2 parents 5e9f3fd + 26fe466 commit 44b8f54

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

_includes/js/queries.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,25 @@ You can skip the first results by setting `skip`. In the old Parse hosted backen
5757
query.skip(10); // skip the first 10 results
5858
```
5959

60+
If you want to know the total number of rows in table satisfying your query, for e.g. pagination purposes - you can use `withCount` (`false` by default). **Note** Enabling this flag will change the structure of response, see example below.
61+
62+
Let's say you have 200 rows in `GameScore` table:
63+
64+
```javascript
65+
const GameScore = Parse.Object.extend("GameScore");
66+
const query = new Parse.Query(GameScore);
67+
68+
query.limit(25);
69+
70+
const results = await query.find(); // [ GameScore, GameScore, ...]
71+
72+
// to include count:
73+
query.withCount(true);
74+
const response = await query.find(); // { results: [ GameScore, ... ], count: 200 }
75+
```
76+
77+
> If you only want to get the count without objects - use [Counting Objects](#counting-objects).
78+
6079
For sortable types like numbers and strings, you can control the order in which results are returned:
6180

6281
```javascript

0 commit comments

Comments
 (0)