@cumulus/db 18.5.1 → 19.1.0
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.
- package/dist/index.d.ts +5 -0
- package/dist/index.js +11 -1
- package/dist/lib/execution.js +13 -6
- package/dist/migrations/20240728101230_add_table_indexes.d.ts +4 -0
- package/dist/migrations/20240728101230_add_table_indexes.js +53 -0
- package/dist/models/execution.d.ts +2 -2
- package/dist/models/execution.js +1 -1
- package/dist/search/BaseSearch.d.ts +187 -0
- package/dist/search/BaseSearch.js +416 -0
- package/dist/search/CollectionSearch.d.ts +79 -0
- package/dist/search/CollectionSearch.js +162 -0
- package/dist/search/ExecutionSearch.d.ts +62 -0
- package/dist/search/ExecutionSearch.js +133 -0
- package/dist/search/GranuleSearch.d.ts +55 -0
- package/dist/search/GranuleSearch.js +109 -0
- package/dist/search/StatsSearch.d.ts +111 -0
- package/dist/search/StatsSearch.js +214 -0
- package/dist/search/field-mapping.d.ts +16 -0
- package/dist/search/field-mapping.js +304 -0
- package/dist/search/queries.d.ts +10 -0
- package/dist/search/queries.js +235 -0
- package/dist/translate/executions.d.ts +6 -0
- package/dist/translate/executions.js +32 -23
- package/dist/translate/granules.d.ts +24 -0
- package/dist/translate/granules.js +48 -27
- package/dist/types/search.d.ts +52 -0
- package/dist/types/search.js +3 -0
- package/package.json +8 -8
package/dist/index.d.ts
CHANGED
|
@@ -30,6 +30,11 @@ export { batchDeleteExecutionFromDatabaseByCumulusCollectionId, executionArnsFro
|
|
|
30
30
|
export { getFilesAndGranuleInfoQuery, } from './lib/file';
|
|
31
31
|
export { getApiGranuleCumulusIds, getApiGranuleExecutionCumulusIds, getGranuleCollectionId, getUniqueGranuleByGranuleId, getGranuleByUniqueColumns, upsertGranuleWithExecutionJoinRecord, getGranulesByApiPropertiesQuery, getGranulesByGranuleId, getGranuleAndCollection, } from './lib/granule';
|
|
32
32
|
export { QuerySearchClient, } from './lib/QuerySearchClient';
|
|
33
|
+
export { BaseSearch, } from './search/BaseSearch';
|
|
34
|
+
export { ExecutionSearch, } from './search/ExecutionSearch';
|
|
35
|
+
export { GranuleSearch, } from './search/GranuleSearch';
|
|
36
|
+
export { StatsSearch, } from './search/StatsSearch';
|
|
37
|
+
export { CollectionSearch, } from './search/CollectionSearch';
|
|
33
38
|
export { AsyncOperationPgModel } from './models/async_operation';
|
|
34
39
|
export { BasePgModel } from './models/base';
|
|
35
40
|
export { CollectionPgModel } from './models/collection';
|
package/dist/index.js
CHANGED
|
@@ -24,7 +24,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.newestExecutionArnFromGranuleIdWorkflowName = exports.getWorkflowNameIntersectFromGranuleIds = exports.getExecutionInfoByGranuleCumulusId = exports.getApiGranuleExecutionCumulusIdsByExecution = exports.getApiExecutionCumulusIds = exports.executionArnsFromGranuleIdsAndWorkflowNames = exports.batchDeleteExecutionFromDatabaseByCumulusCollectionId = exports.getCollectionsByGranuleIds = exports.translatePostgresPdrToApiPdr = exports.translateApiPdrToPostgresPdr = exports.translatePostgresGranuleResultToApiGranule = exports.translatePostgresGranuleToApiGranule = exports.translateApiGranuleToPostgresGranuleWithoutNilsRemoved = exports.translateApiGranuleToPostgresGranule = exports.translatePostgresExecutionToApiExecution = exports.translateApiExecutionToPostgresExecutionWithoutNilsRemoved = exports.translateApiExecutionToPostgresExecution = exports.translateApiRuleToPostgresRuleRaw = exports.translateApiRuleToPostgresRule = exports.translatePostgresRuleToApiRule = exports.translatePostgresProviderToApiProvider = exports.translateApiProviderToPostgresProvider = exports.translatePostgresCollectionToApiCollection = exports.translateApiCollectionToPostgresCollection = exports.translatePostgresFileToApiFile = exports.translateApiFiletoPostgresFile = exports.translatePostgresAsyncOperationToApiAsyncOperation = exports.translateApiAsyncOperationToPostgresAsyncOperation = exports.nullifyUndefinedProviderValues = exports.validateProviderHost = exports.migrationDir = exports.TableNames = exports.createRejectableTransaction = exports.localStackConnectionEnv = exports.getKnexConfig = exports.getKnexClient = exports.isCollisionError = exports.generateLocalTestDb = exports.fakeRuleRecordFactory = exports.fakeProviderRecordFactory = exports.fakePdrRecordFactory = exports.fakeGranuleRecordFactory = exports.fakeFileRecordFactory = exports.fakeExecutionRecordFactory = exports.fakeCollectionRecordFactory = exports.fakeAsyncOperationRecordFactory = exports.destroyLocalTestDb = exports.deleteTestDatabase = exports.createTestDatabase = exports.Knex = void 0;
|
|
27
|
-
exports.RulePgModel = exports.ProviderPgModel = exports.PdrPgModel = exports.GranulesExecutionsPgModel = exports.GranulePgModel = exports.FilePgModel = exports.ExecutionPgModel = exports.CollectionPgModel = exports.BasePgModel = exports.AsyncOperationPgModel = exports.QuerySearchClient = exports.getGranuleAndCollection = exports.getGranulesByGranuleId = exports.getGranulesByApiPropertiesQuery = exports.upsertGranuleWithExecutionJoinRecord = exports.getGranuleByUniqueColumns = exports.getUniqueGranuleByGranuleId = exports.getGranuleCollectionId = exports.getApiGranuleExecutionCumulusIds = exports.getApiGranuleCumulusIds = exports.getFilesAndGranuleInfoQuery = void 0;
|
|
27
|
+
exports.RulePgModel = exports.ProviderPgModel = exports.PdrPgModel = exports.GranulesExecutionsPgModel = exports.GranulePgModel = exports.FilePgModel = exports.ExecutionPgModel = exports.CollectionPgModel = exports.BasePgModel = exports.AsyncOperationPgModel = exports.CollectionSearch = exports.StatsSearch = exports.GranuleSearch = exports.ExecutionSearch = exports.BaseSearch = exports.QuerySearchClient = exports.getGranuleAndCollection = exports.getGranulesByGranuleId = exports.getGranulesByApiPropertiesQuery = exports.upsertGranuleWithExecutionJoinRecord = exports.getGranuleByUniqueColumns = exports.getUniqueGranuleByGranuleId = exports.getGranuleCollectionId = exports.getApiGranuleExecutionCumulusIds = exports.getApiGranuleCumulusIds = exports.getFilesAndGranuleInfoQuery = void 0;
|
|
28
28
|
const path = __importStar(require("path"));
|
|
29
29
|
var knex_1 = require("knex");
|
|
30
30
|
Object.defineProperty(exports, "Knex", { enumerable: true, get: function () { return knex_1.Knex; } });
|
|
@@ -108,6 +108,16 @@ Object.defineProperty(exports, "getGranulesByGranuleId", { enumerable: true, get
|
|
|
108
108
|
Object.defineProperty(exports, "getGranuleAndCollection", { enumerable: true, get: function () { return granule_1.getGranuleAndCollection; } });
|
|
109
109
|
var QuerySearchClient_1 = require("./lib/QuerySearchClient");
|
|
110
110
|
Object.defineProperty(exports, "QuerySearchClient", { enumerable: true, get: function () { return QuerySearchClient_1.QuerySearchClient; } });
|
|
111
|
+
var BaseSearch_1 = require("./search/BaseSearch");
|
|
112
|
+
Object.defineProperty(exports, "BaseSearch", { enumerable: true, get: function () { return BaseSearch_1.BaseSearch; } });
|
|
113
|
+
var ExecutionSearch_1 = require("./search/ExecutionSearch");
|
|
114
|
+
Object.defineProperty(exports, "ExecutionSearch", { enumerable: true, get: function () { return ExecutionSearch_1.ExecutionSearch; } });
|
|
115
|
+
var GranuleSearch_1 = require("./search/GranuleSearch");
|
|
116
|
+
Object.defineProperty(exports, "GranuleSearch", { enumerable: true, get: function () { return GranuleSearch_1.GranuleSearch; } });
|
|
117
|
+
var StatsSearch_1 = require("./search/StatsSearch");
|
|
118
|
+
Object.defineProperty(exports, "StatsSearch", { enumerable: true, get: function () { return StatsSearch_1.StatsSearch; } });
|
|
119
|
+
var CollectionSearch_1 = require("./search/CollectionSearch");
|
|
120
|
+
Object.defineProperty(exports, "CollectionSearch", { enumerable: true, get: function () { return CollectionSearch_1.CollectionSearch; } });
|
|
111
121
|
var async_operation_1 = require("./models/async_operation");
|
|
112
122
|
Object.defineProperty(exports, "AsyncOperationPgModel", { enumerable: true, get: function () { return async_operation_1.AsyncOperationPgModel; } });
|
|
113
123
|
var base_1 = require("./models/base");
|
package/dist/lib/execution.js
CHANGED
|
@@ -115,20 +115,27 @@ const getWorkflowNameIntersectFromGranuleIds = async (knexOrTransaction, granule
|
|
|
115
115
|
const numberOfGranules = granuleCumulusIdsArray.length;
|
|
116
116
|
const { executions: executionsTable, granulesExecutions: granulesExecutionsTable } = tables_1.TableNames;
|
|
117
117
|
const aggregatedWorkflowCounts = await knexOrTransaction(executionsTable)
|
|
118
|
-
.select('workflow_name')
|
|
119
|
-
.countDistinct('granule_cumulus_id')
|
|
118
|
+
.select(['workflow_name'])
|
|
120
119
|
.innerJoin(granulesExecutionsTable, `${executionsTable}.cumulus_id`, `${granulesExecutionsTable}.execution_cumulus_id`)
|
|
121
120
|
.whereIn('granule_cumulus_id', granuleCumulusIdsArray)
|
|
122
121
|
.groupBy('workflow_name')
|
|
122
|
+
.countDistinct('granule_cumulus_id')
|
|
123
123
|
.havingRaw('count(distinct granule_cumulus_id) = ?', [numberOfGranules])
|
|
124
124
|
.modify((queryBuilder) => {
|
|
125
125
|
if (numberOfGranules === 1) {
|
|
126
|
-
queryBuilder.
|
|
127
|
-
.orderBy('timestamp', 'desc');
|
|
126
|
+
queryBuilder.min('timestamp');
|
|
128
127
|
}
|
|
129
128
|
});
|
|
130
|
-
|
|
131
|
-
|
|
129
|
+
/*
|
|
130
|
+
sort (and group by) in knex causes an edge case where two distinct workflows
|
|
131
|
+
of the same name will be returned if they have different timestamps. This means
|
|
132
|
+
different returns depending on whether you have asked for one or multiple granules
|
|
133
|
+
hence this sort has been moved to js logic
|
|
134
|
+
*/
|
|
135
|
+
if (numberOfGranules === 1) {
|
|
136
|
+
aggregatedWorkflowCounts.sort((a, b) => b.min - a.min);
|
|
137
|
+
}
|
|
138
|
+
return aggregatedWorkflowCounts.map((workflowCounts) => workflowCounts.workflow_name);
|
|
132
139
|
};
|
|
133
140
|
exports.getWorkflowNameIntersectFromGranuleIds = getWorkflowNameIntersectFromGranuleIds;
|
|
134
141
|
/**
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.down = exports.up = void 0;
|
|
4
|
+
const up = async (knex) => {
|
|
5
|
+
await knex.raw('CREATE INDEX CONCURRENTLY IF NOT EXISTS async_operations_updated_at_index ON async_operations(updated_at)');
|
|
6
|
+
await knex.raw('CREATE INDEX CONCURRENTLY IF NOT EXISTS async_operations_status_operation_type_cumulus_id_index ON async_operations(status, operation_type, cumulus_id)');
|
|
7
|
+
await knex.raw('CREATE INDEX CONCURRENTLY IF NOT EXISTS collections_updated_at_index ON collections(updated_at)');
|
|
8
|
+
await knex.raw('CREATE INDEX CONCURRENTLY IF NOT EXISTS executions_updated_at_index ON executions(updated_at)');
|
|
9
|
+
await knex.raw('CREATE INDEX CONCURRENTLY IF NOT EXISTS executions_status_collection_cumulus_id_index ON executions(status, collection_cumulus_id, cumulus_id)');
|
|
10
|
+
await knex.raw('CREATE INDEX CONCURRENTLY IF NOT EXISTS files_updated_at_index ON files(updated_at)');
|
|
11
|
+
await knex.raw('CREATE INDEX CONCURRENTLY IF NOT EXISTS granules_updated_at_index ON granules(updated_at)');
|
|
12
|
+
await knex.raw('CREATE INDEX CONCURRENTLY IF NOT EXISTS granules_coll_status_processendtime_cumulus_id_index ON granules(collection_cumulus_id, status, processing_end_date_time, cumulus_id)');
|
|
13
|
+
await knex.raw('CREATE INDEX CONCURRENTLY IF NOT EXISTS granules_status_provider_collection_cumulus_id_index ON granules(status, provider_cumulus_id, collection_cumulus_id, cumulus_id)');
|
|
14
|
+
await knex.raw('CREATE INDEX CONCURRENTLY IF NOT EXISTS pdrs_updated_at_index ON pdrs(updated_at)');
|
|
15
|
+
await knex.raw('CREATE INDEX CONCURRENTLY IF NOT EXISTS pdrs_status_provider_collection_cumulus_id_index ON pdrs(status, provider_cumulus_id, collection_cumulus_id, cumulus_id)');
|
|
16
|
+
await knex.raw('CREATE INDEX CONCURRENTLY IF NOT EXISTS pdrs_execution_cumulus_id_index ON pdrs(execution_cumulus_id)');
|
|
17
|
+
await knex.raw('CREATE INDEX CONCURRENTLY IF NOT EXISTS pdrs_coll_status_cumulus_id_index ON pdrs(collection_cumulus_id, status, cumulus_id)');
|
|
18
|
+
await knex.raw('CREATE INDEX CONCURRENTLY IF NOT EXISTS pdrs_provider_collection_cumulus_id_name_index ON pdrs(provider_cumulus_id, collection_cumulus_id, name)');
|
|
19
|
+
await knex.raw('CREATE INDEX CONCURRENTLY IF NOT EXISTS providers_updated_at_index ON providers(updated_at)');
|
|
20
|
+
await knex.raw('CREATE INDEX CONCURRENTLY IF NOT EXISTS rules_updated_at_index ON rules(updated_at)');
|
|
21
|
+
await knex.raw('VACUUM (ANALYZE, VERBOSE) async_operations');
|
|
22
|
+
await knex.raw('VACUUM (ANALYZE, VERBOSE) collections');
|
|
23
|
+
await knex.raw('VACUUM (ANALYZE, VERBOSE) executions');
|
|
24
|
+
await knex.raw('VACUUM (ANALYZE, VERBOSE) files');
|
|
25
|
+
await knex.raw('VACUUM (ANALYZE, VERBOSE) granules');
|
|
26
|
+
await knex.raw('VACUUM (ANALYZE, VERBOSE) pdrs');
|
|
27
|
+
await knex.raw('VACUUM (ANALYZE, VERBOSE) providers');
|
|
28
|
+
await knex.raw('VACUUM (ANALYZE, VERBOSE) rules');
|
|
29
|
+
};
|
|
30
|
+
exports.up = up;
|
|
31
|
+
const down = async (knex) => {
|
|
32
|
+
await knex.raw('DROP INDEX CONCURRENTLY IF EXISTS async_operations_updated_at_index');
|
|
33
|
+
await knex.raw('DROP INDEX CONCURRENTLY IF EXISTS async_operations_status_operation_type_cumulus_id_index');
|
|
34
|
+
await knex.raw('DROP INDEX CONCURRENTLY IF EXISTS collections_updated_at_index');
|
|
35
|
+
await knex.raw('DROP INDEX CONCURRENTLY IF EXISTS executions_updated_at_index');
|
|
36
|
+
await knex.raw('DROP INDEX CONCURRENTLY IF EXISTS executions_status_collection_cumulus_id_index');
|
|
37
|
+
await knex.raw('DROP INDEX CONCURRENTLY IF EXISTS files_updated_at_index');
|
|
38
|
+
await knex.raw('DROP INDEX CONCURRENTLY IF EXISTS granules_updated_at_index');
|
|
39
|
+
await knex.raw('DROP INDEX CONCURRENTLY IF EXISTS granules_coll_status_processendtime_cumulus_id_index');
|
|
40
|
+
await knex.raw('DROP INDEX CONCURRENTLY IF EXISTS granules_status_provider_collection_cumulus_id_index');
|
|
41
|
+
await knex.raw('DROP INDEX CONCURRENTLY IF EXISTS pdrs_updated_at_index');
|
|
42
|
+
await knex.raw('DROP INDEX CONCURRENTLY IF EXISTS pdrs_status_provider_collection_cumulus_id_index');
|
|
43
|
+
await knex.raw('DROP INDEX CONCURRENTLY IF EXISTS pdrs_execution_cumulus_id_index');
|
|
44
|
+
await knex.raw('DROP INDEX CONCURRENTLY IF EXISTS pdrs_coll_status_cumulus_id_index');
|
|
45
|
+
await knex.raw('DROP INDEX CONCURRENTLY IF EXISTS pdrs_provider_collection_cumulus_id_name_index');
|
|
46
|
+
await knex.raw('DROP INDEX CONCURRENTLY IF EXISTS providers_updated_at_index');
|
|
47
|
+
await knex.raw('DROP INDEX CONCURRENTLY IF EXISTS rules_updated_at_index');
|
|
48
|
+
};
|
|
49
|
+
exports.down = down;
|
|
50
|
+
exports.config = {
|
|
51
|
+
transaction: false,
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=20240728101230_add_table_indexes.js.map
|
|
@@ -16,12 +16,12 @@ declare class ExecutionPgModel extends BasePgModel<PostgresExecution, PostgresEx
|
|
|
16
16
|
* @param {Object} [params] - Optional object with addition params for query
|
|
17
17
|
* @param {number} [params.limit] - number of records to be returned
|
|
18
18
|
* @param {number} [params.offset] - record offset
|
|
19
|
-
* @returns
|
|
19
|
+
* @returns An array of executions
|
|
20
20
|
*/
|
|
21
21
|
searchByCumulusIds(knexOrTrx: Knex | Knex.Transaction, executionCumulusIds: Array<number> | number, params: {
|
|
22
22
|
limit: number;
|
|
23
23
|
offset: number;
|
|
24
|
-
}): Promise<Array<
|
|
24
|
+
}): Promise<Array<PostgresExecutionRecord>>;
|
|
25
25
|
}
|
|
26
26
|
export { ExecutionPgModel };
|
|
27
27
|
//# sourceMappingURL=execution.d.ts.map
|
package/dist/models/execution.js
CHANGED
|
@@ -42,7 +42,7 @@ class ExecutionPgModel extends base_1.BasePgModel {
|
|
|
42
42
|
* @param {Object} [params] - Optional object with addition params for query
|
|
43
43
|
* @param {number} [params.limit] - number of records to be returned
|
|
44
44
|
* @param {number} [params.offset] - record offset
|
|
45
|
-
* @returns
|
|
45
|
+
* @returns An array of executions
|
|
46
46
|
*/
|
|
47
47
|
async searchByCumulusIds(knexOrTrx, executionCumulusIds, params) {
|
|
48
48
|
const { limit, offset, ...sortQueries } = params || {};
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { Knex } from 'knex';
|
|
2
|
+
import { BaseRecord } from '../types/base';
|
|
3
|
+
import { DbQueryParameters, QueryEvent, QueryStringParameters } from '../types/search';
|
|
4
|
+
export declare const typeToTable: {
|
|
5
|
+
[key: string]: string;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Class to build and execute db search query
|
|
9
|
+
*/
|
|
10
|
+
declare class BaseSearch {
|
|
11
|
+
readonly type: string;
|
|
12
|
+
readonly tableName: string;
|
|
13
|
+
readonly queryStringParameters: QueryStringParameters;
|
|
14
|
+
dbQueryParameters: DbQueryParameters;
|
|
15
|
+
constructor(event: QueryEvent, type: string);
|
|
16
|
+
/**
|
|
17
|
+
* check if joined collections table search is needed
|
|
18
|
+
*
|
|
19
|
+
* @returns whether collection search is needed
|
|
20
|
+
*/
|
|
21
|
+
protected searchCollection(): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* check if joined pdrs table search is needed
|
|
24
|
+
*
|
|
25
|
+
* @returns whether pdr search is needed
|
|
26
|
+
*/
|
|
27
|
+
protected searchPdr(): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* check if joined providers table search is needed
|
|
30
|
+
*
|
|
31
|
+
* @returns whether provider search is needed
|
|
32
|
+
*/
|
|
33
|
+
protected searchProvider(): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Determine if an estimated row count should be returned
|
|
36
|
+
*
|
|
37
|
+
* @param countSql - sql statement for count
|
|
38
|
+
* @returns whether an estimated row count should be returned
|
|
39
|
+
*/
|
|
40
|
+
protected shouldEstimateRowcount(countSql: string): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Build the search query
|
|
43
|
+
*
|
|
44
|
+
* @param knex - DB client
|
|
45
|
+
* @returns queries for getting count and search result
|
|
46
|
+
*/
|
|
47
|
+
protected buildSearch(knex: Knex): {
|
|
48
|
+
countQuery?: Knex.QueryBuilder;
|
|
49
|
+
searchQuery: Knex.QueryBuilder;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Get metadata template for query result
|
|
53
|
+
*
|
|
54
|
+
* @returns metadata template
|
|
55
|
+
*/
|
|
56
|
+
private _metaTemplate;
|
|
57
|
+
/**
|
|
58
|
+
* Build basic query
|
|
59
|
+
*
|
|
60
|
+
* @param knex - DB client
|
|
61
|
+
* @throws - function is not implemented
|
|
62
|
+
*/
|
|
63
|
+
protected buildBasicQuery(knex: Knex): {
|
|
64
|
+
countQuery?: Knex.QueryBuilder;
|
|
65
|
+
searchQuery: Knex.QueryBuilder;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Build queries for infix and prefix
|
|
69
|
+
*
|
|
70
|
+
* @param params
|
|
71
|
+
* @param [params.countQuery] - query builder for getting count
|
|
72
|
+
* @param params.searchQuery - query builder for search
|
|
73
|
+
* @param [params.dbQueryParameters] - db query parameters
|
|
74
|
+
*/
|
|
75
|
+
protected buildInfixPrefixQuery(params: {
|
|
76
|
+
countQuery?: Knex.QueryBuilder;
|
|
77
|
+
searchQuery: Knex.QueryBuilder;
|
|
78
|
+
dbQueryParameters?: DbQueryParameters;
|
|
79
|
+
}): void;
|
|
80
|
+
/**
|
|
81
|
+
* Build queries for checking if field 'exists'
|
|
82
|
+
*
|
|
83
|
+
* @param params
|
|
84
|
+
* @param [params.countQuery] - query builder for getting count
|
|
85
|
+
* @param params.searchQuery - query builder for search
|
|
86
|
+
* @param [params.dbQueryParameters] - db query parameters
|
|
87
|
+
*/
|
|
88
|
+
protected buildExistsQuery(params: {
|
|
89
|
+
countQuery?: Knex.QueryBuilder;
|
|
90
|
+
searchQuery: Knex.QueryBuilder;
|
|
91
|
+
dbQueryParameters?: DbQueryParameters;
|
|
92
|
+
}): void;
|
|
93
|
+
/**
|
|
94
|
+
* Build queries for range fields
|
|
95
|
+
*
|
|
96
|
+
* @param params
|
|
97
|
+
* @param params.knex - db client
|
|
98
|
+
* @param [params.countQuery] - query builder for getting count
|
|
99
|
+
* @param params.searchQuery - query builder for search
|
|
100
|
+
* @param [params.dbQueryParameters] - db query parameters
|
|
101
|
+
*/
|
|
102
|
+
protected buildRangeQuery(params: {
|
|
103
|
+
knex?: Knex;
|
|
104
|
+
countQuery?: Knex.QueryBuilder;
|
|
105
|
+
searchQuery: Knex.QueryBuilder;
|
|
106
|
+
dbQueryParameters?: DbQueryParameters;
|
|
107
|
+
}): void;
|
|
108
|
+
/**
|
|
109
|
+
* Build queries for term fields
|
|
110
|
+
*
|
|
111
|
+
* @param params
|
|
112
|
+
* @param [params.countQuery] - query builder for getting count
|
|
113
|
+
* @param params.searchQuery - query builder for search
|
|
114
|
+
* @param [params.dbQueryParameters] - db query parameters
|
|
115
|
+
*/
|
|
116
|
+
protected buildTermQuery(params: {
|
|
117
|
+
countQuery?: Knex.QueryBuilder;
|
|
118
|
+
searchQuery: Knex.QueryBuilder;
|
|
119
|
+
dbQueryParameters?: DbQueryParameters;
|
|
120
|
+
}): void;
|
|
121
|
+
/**
|
|
122
|
+
* Build queries for terms fields
|
|
123
|
+
*
|
|
124
|
+
* @param params
|
|
125
|
+
* @param [params.countQuery] - query builder for getting count
|
|
126
|
+
* @param params.searchQuery - query builder for search
|
|
127
|
+
* @param [params.dbQueryParameters] - db query parameters
|
|
128
|
+
*/
|
|
129
|
+
protected buildTermsQuery(params: {
|
|
130
|
+
countQuery?: Knex.QueryBuilder;
|
|
131
|
+
searchQuery: Knex.QueryBuilder;
|
|
132
|
+
dbQueryParameters?: DbQueryParameters;
|
|
133
|
+
}): void;
|
|
134
|
+
/**
|
|
135
|
+
* Build queries for checking if field doesn't match the given value
|
|
136
|
+
*
|
|
137
|
+
* @param params
|
|
138
|
+
* @param [params.countQuery] - query builder for getting count
|
|
139
|
+
* @param params.searchQuery - query builder for search
|
|
140
|
+
* @param [params.dbQueryParameters] - db query parameters
|
|
141
|
+
*/
|
|
142
|
+
protected buildNotMatchQuery(params: {
|
|
143
|
+
countQuery?: Knex.QueryBuilder;
|
|
144
|
+
searchQuery: Knex.QueryBuilder;
|
|
145
|
+
dbQueryParameters?: DbQueryParameters;
|
|
146
|
+
}): void;
|
|
147
|
+
/**
|
|
148
|
+
* Build queries for sort keys and fields
|
|
149
|
+
*
|
|
150
|
+
* @param params
|
|
151
|
+
* @param params.searchQuery - query builder for search
|
|
152
|
+
* @param [params.dbQueryParameters] - db query parameters
|
|
153
|
+
*/
|
|
154
|
+
protected buildSortQuery(params: {
|
|
155
|
+
searchQuery: Knex.QueryBuilder;
|
|
156
|
+
dbQueryParameters?: DbQueryParameters;
|
|
157
|
+
}): void;
|
|
158
|
+
/**
|
|
159
|
+
* Translate postgres records to api records
|
|
160
|
+
*
|
|
161
|
+
* @param pgRecords - postgres records returned from query
|
|
162
|
+
* @param [knex] - knex client for additional queries if neccessary
|
|
163
|
+
* @throws - function is not implemented
|
|
164
|
+
*/
|
|
165
|
+
protected translatePostgresRecordsToApiRecords(pgRecords: BaseRecord[], knex?: Knex): void;
|
|
166
|
+
/**
|
|
167
|
+
* Get estimated table rowcount
|
|
168
|
+
*
|
|
169
|
+
* @param params
|
|
170
|
+
* @param params.knex - DB client
|
|
171
|
+
* @param [params.tableName] - table name
|
|
172
|
+
* @returns rowcount
|
|
173
|
+
*/
|
|
174
|
+
protected getEstimatedRowcount(params: {
|
|
175
|
+
knex: Knex;
|
|
176
|
+
tableName?: string;
|
|
177
|
+
}): Promise<number>;
|
|
178
|
+
/**
|
|
179
|
+
* Build and execute search query
|
|
180
|
+
*
|
|
181
|
+
* @param testKnex - knex for testing
|
|
182
|
+
* @returns search result
|
|
183
|
+
*/
|
|
184
|
+
query(testKnex?: Knex): Promise<any>;
|
|
185
|
+
}
|
|
186
|
+
export { BaseSearch };
|
|
187
|
+
//# sourceMappingURL=BaseSearch.d.ts.map
|