Skip to content

Commit

Permalink
Merge pull request #1 from BufferUnderflower/BufferUnderflower-withCount
Browse files Browse the repository at this point in the history
Documentation for ParseQuery.withCount
  • Loading branch information
BufferUnderflower authored Jul 21, 2019
2 parents 5e9f3fd + 26fe466 commit 44b8f54
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions _includes/js/queries.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,25 @@ You can skip the first results by setting `skip`. In the old Parse hosted backen
query.skip(10); // skip the first 10 results
```

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.

Let's say you have 200 rows in `GameScore` table:

```javascript
const GameScore = Parse.Object.extend("GameScore");
const query = new Parse.Query(GameScore);

query.limit(25);

const results = await query.find(); // [ GameScore, GameScore, ...]

// to include count:
query.withCount(true);
const response = await query.find(); // { results: [ GameScore, ... ], count: 200 }
```

> If you only want to get the count without objects - use [Counting Objects](#counting-objects).
For sortable types like numbers and strings, you can control the order in which results are returned:

```javascript
Expand Down

0 comments on commit 44b8f54

Please sign in to comment.