From 26fe4669ebff9e4d1a03a0515f1789d302d30c1a Mon Sep 17 00:00:00 2001 From: Old Grandpa Date: Sun, 21 Jul 2019 14:40:37 +0300 Subject: [PATCH 1/6] Documentation for ParseQuery.withCount See: https://github.com/parse-community/Parse-SDK-JS/issues/865 https://github.com/parse-community/Parse-SDK-JS/pull/868 --- _includes/js/queries.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/_includes/js/queries.md b/_includes/js/queries.md index 2d8da30f7..5caf1776a 100644 --- a/_includes/js/queries.md +++ b/_includes/js/queries.md @@ -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 From 88cc0392c2e6293c426ce64441bf328084916575 Mon Sep 17 00:00:00 2001 From: Old Grandpa Date: Sun, 21 Jul 2019 15:53:42 +0300 Subject: [PATCH 2/6] added disclaimer --- _includes/js/queries.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/_includes/js/queries.md b/_includes/js/queries.md index 5caf1776a..bd209a98b 100644 --- a/_includes/js/queries.md +++ b/_includes/js/queries.md @@ -59,6 +59,8 @@ 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 @@ -73,7 +75,7 @@ const results = await query.find(); // [ GameScore, GameScore, ...] query.withCount(true); const response = await query.find(); // { results: [ GameScore, ... ], count: 200 } ``` - +⚠️ Сount operations can be slow and expensive. > 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: From 14a3b412abd49773f16c74c0b77bf20a1ab5b355 Mon Sep 17 00:00:00 2001 From: Old Grandpa Date: Sun, 21 Jul 2019 15:55:31 +0300 Subject: [PATCH 3/6] remove extra line breaks --- _includes/js/queries.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/_includes/js/queries.md b/_includes/js/queries.md index bd209a98b..d44eae3b4 100644 --- a/_includes/js/queries.md +++ b/_includes/js/queries.md @@ -59,8 +59,6 @@ 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 From bc56dc2e77928aae6bf0c16ee46f1001349fcbb0 Mon Sep 17 00:00:00 2001 From: Old Grandpa Date: Sun, 21 Jul 2019 17:20:40 +0300 Subject: [PATCH 4/6] Update _includes/js/queries.md Co-Authored-By: Tom Fox --- _includes/js/queries.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/_includes/js/queries.md b/_includes/js/queries.md index d44eae3b4..52a32dc25 100644 --- a/_includes/js/queries.md +++ b/_includes/js/queries.md @@ -57,7 +57,9 @@ 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. +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` (`false` by default). + +**Note:** Enabling this flag will change the structure of response, see the example below. Let's say you have 200 rows in `GameScore` table: From dc7ba42313e61065669d142c8cd7bfbc467f4c66 Mon Sep 17 00:00:00 2001 From: Old Grandpa Date: Sun, 21 Jul 2019 17:21:06 +0300 Subject: [PATCH 5/6] Update _includes/js/queries.md Co-Authored-By: Tom Fox --- _includes/js/queries.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_includes/js/queries.md b/_includes/js/queries.md index 52a32dc25..0f78ee570 100644 --- a/_includes/js/queries.md +++ b/_includes/js/queries.md @@ -61,7 +61,7 @@ If you want to know the total number of rows in a table satisfying your query, f **Note:** Enabling this flag will change the structure of response, see the example below. -Let's say you have 200 rows in `GameScore` table: +Let's say you have 200 rows in a table called `GameScore`: ```javascript const GameScore = Parse.Object.extend("GameScore"); From 67748e62e2070a283c18741b83d94d2e48380037 Mon Sep 17 00:00:00 2001 From: Old Grandpa Date: Tue, 23 Jul 2019 12:24:59 +0300 Subject: [PATCH 6/6] simpler --- _includes/js/queries.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/_includes/js/queries.md b/_includes/js/queries.md index 0f78ee570..e0e024660 100644 --- a/_includes/js/queries.md +++ b/_includes/js/queries.md @@ -57,7 +57,7 @@ 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 a table satisfying your query, for e.g. pagination purposes - you can use `withCount` (`false` by default). +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`. **Note:** Enabling this flag will change the structure of response, see the example below. @@ -72,7 +72,7 @@ query.limit(25); const results = await query.find(); // [ GameScore, GameScore, ...] // to include count: -query.withCount(true); +query.withCount(); const response = await query.find(); // { results: [ GameScore, ... ], count: 200 } ``` ⚠️ Сount operations can be slow and expensive.