@cumulus/db 20.1.0 → 20.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -419,9 +419,11 @@ class BaseSearch {
419
419
  const getEstimate = shouldEstimateRowcount
420
420
  ? this.getEstimatedRowcount({ knex })
421
421
  : undefined;
422
+ const shouldReturnCountOnly = this.dbQueryParameters.countOnly === true;
422
423
  try {
423
424
  const [countResult, pgRecords] = await Promise.all([
424
- getEstimate || countQuery, searchQuery,
425
+ getEstimate || countQuery,
426
+ shouldReturnCountOnly ? [] : searchQuery,
425
427
  ]);
426
428
  const meta = this._metaTemplate();
427
429
  meta.limit = this.dbQueryParameters.limit;
@@ -22,6 +22,7 @@ const reservedWords = [
22
22
  'fields',
23
23
  'includeFullRecord',
24
24
  'searchContext',
25
+ 'countOnly',
25
26
  ];
26
27
  /**
27
28
  * regexp for matching api query string parameter to query type
@@ -211,7 +212,7 @@ const convert = {
211
212
  * @returns db query parameters
212
213
  */
213
214
  const convertQueryStringToDbQueryParameters = (type, queryStringParameters) => {
214
- const { limit, page, prefix, infix, fields, estimateTableRowCount, includeFullRecord, } = queryStringParameters;
215
+ const { limit, page, prefix, infix, fields, estimateTableRowCount, includeFullRecord, countOnly, } = queryStringParameters;
215
216
  const dbQueryParameters = {};
216
217
  dbQueryParameters.page = Number.parseInt(page ?? '1', 10);
217
218
  if (limit !== 'null') {
@@ -226,6 +227,7 @@ const convertQueryStringToDbQueryParameters = (type, queryStringParameters) => {
226
227
  dbQueryParameters.fields = fields.split(',');
227
228
  dbQueryParameters.estimateTableRowCount = (estimateTableRowCount === 'true');
228
229
  dbQueryParameters.includeFullRecord = (includeFullRecord === 'true');
230
+ dbQueryParameters.countOnly = (countOnly === 'true');
229
231
  dbQueryParameters.sort = convertSort(type, queryStringParameters);
230
232
  // remove reserved words (that are not fields)
231
233
  const fieldParams = (0, omit_1.default)(queryStringParameters, reservedWords);
@@ -1,4 +1,5 @@
1
1
  export declare type QueryStringParameters = {
2
+ countOnly?: string;
2
3
  field?: string;
3
4
  fields?: string;
4
5
  infix?: string;
@@ -25,6 +26,7 @@ export declare type SortType = {
25
26
  };
26
27
  export declare type DbQueryParameters = {
27
28
  collate?: string;
29
+ countOnly?: boolean;
28
30
  fields?: string[];
29
31
  infix?: string;
30
32
  limit?: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cumulus/db",
3
- "version": "20.1.0",
3
+ "version": "20.1.2",
4
4
  "description": "Utilities for working with the Cumulus DB",
5
5
  "license": "Apache-2.0",
6
6
  "main": "./dist/index.js",
@@ -33,12 +33,12 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "@aws-sdk/client-secrets-manager": "^3.621.0",
36
- "@cumulus/aws-client": "20.1.0",
37
- "@cumulus/common": "20.1.0",
38
- "@cumulus/errors": "20.1.0",
39
- "@cumulus/logger": "20.1.0",
40
- "@cumulus/message": "20.1.0",
41
- "@cumulus/types": "20.1.0",
36
+ "@cumulus/aws-client": "20.1.2",
37
+ "@cumulus/common": "20.1.2",
38
+ "@cumulus/errors": "20.1.2",
39
+ "@cumulus/logger": "20.1.2",
40
+ "@cumulus/message": "20.1.2",
41
+ "@cumulus/types": "20.1.2",
42
42
  "crypto-random-string": "^3.2.0",
43
43
  "is-valid-hostname": "1.0.2",
44
44
  "knex": "2.4.1",
@@ -50,5 +50,5 @@
50
50
  "devDependencies": {
51
51
  "@types/uuid": "^8.0.0"
52
52
  },
53
- "gitHead": "c2ecf1ce2ae86a16639848c7d42b579a7380c2f3"
53
+ "gitHead": "051ef1428ac21105fd55370d15e26009f4b49f57"
54
54
  }