@squiz/db-lib 1.22.1-alpha.9 → 1.28.1-alpha.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,35 +3,35 @@
3
3
  2 info using node@v18.15.0
4
4
  3 timing npm:load:whichnode Completed in 1ms
5
5
  4 timing config:load:defaults Completed in 2ms
6
- 5 timing config:load:file:/usr/local/lib/node_modules/npm/npmrc Completed in 0ms
7
- 6 timing config:load:builtin Completed in 0ms
8
- 7 timing config:load:cli Completed in 1ms
9
- 8 timing config:load:env Completed in 2ms
6
+ 5 timing config:load:file:/usr/local/lib/node_modules/npm/npmrc Completed in 1ms
7
+ 6 timing config:load:builtin Completed in 1ms
8
+ 7 timing config:load:cli Completed in 2ms
9
+ 8 timing config:load:env Completed in 1ms
10
10
  9 info found workspace root at /builds/developer-experience/cmp
11
11
  10 timing config:load:file:/builds/developer-experience/cmp/.npmrc Completed in 0ms
12
- 11 timing config:load:project Completed in 19ms
12
+ 11 timing config:load:project Completed in 22ms
13
13
  12 timing config:load:file:/root/.npmrc Completed in 1ms
14
14
  13 timing config:load:user Completed in 1ms
15
15
  14 timing config:load:file:/usr/local/etc/npmrc Completed in 0ms
16
16
  15 timing config:load:global Completed in 0ms
17
17
  16 timing config:load:setEnvs Completed in 1ms
18
- 17 timing config:load Completed in 28ms
19
- 18 timing npm:load:configload Completed in 28ms
18
+ 17 timing config:load Completed in 31ms
19
+ 18 timing npm:load:configload Completed in 32ms
20
20
  19 timing npm:load:mkdirpcache Completed in 0ms
21
- 20 timing npm:load:mkdirplogs Completed in 1ms
21
+ 20 timing npm:load:mkdirplogs Completed in 0ms
22
22
  21 verbose title npm run compile
23
23
  22 verbose argv "run" "compile" "--"
24
- 23 timing npm:load:setTitle Completed in 1ms
25
- 24 timing config:load:flatten Completed in 6ms
26
- 25 timing npm:load:display Completed in 8ms
27
- 26 verbose logfile logs-max:10 dir:/builds/developer-experience/cmp/packages/db-lib/.npm/_logs/2023-04-05T04_03_00_683Z-
28
- 27 verbose logfile /builds/developer-experience/cmp/packages/db-lib/.npm/_logs/2023-04-05T04_03_00_683Z-debug-0.log
29
- 28 timing npm:load:logFile Completed in 5ms
24
+ 23 timing npm:load:setTitle Completed in 2ms
25
+ 24 timing config:load:flatten Completed in 4ms
26
+ 25 timing npm:load:display Completed in 5ms
27
+ 26 verbose logfile logs-max:10 dir:/builds/developer-experience/cmp/packages/db-lib/.npm/_logs/2023-04-13T05_18_37_048Z-
28
+ 27 verbose logfile /builds/developer-experience/cmp/packages/db-lib/.npm/_logs/2023-04-13T05_18_37_048Z-debug-0.log
29
+ 28 timing npm:load:logFile Completed in 3ms
30
30
  29 timing npm:load:timers Completed in 0ms
31
- 30 timing npm:load:configScope Completed in 0ms
31
+ 30 timing npm:load:configScope Completed in 1ms
32
32
  31 timing npm:load Completed in 46ms
33
33
  32 silly logfile done cleaning log files
34
- 33 timing command:run Completed in 2646ms
34
+ 33 timing command:run Completed in 3041ms
35
35
  34 verbose exit 0
36
- 35 timing npm Completed in 2705ms
36
+ 35 timing npm Completed in 3100ms
37
37
  36 info ok
@@ -51,5 +51,5 @@ export declare abstract class AbstractRepository<SHAPE extends object, DATA_CLAS
51
51
  getCount(item?: Partial<SHAPE> | null): Promise<number>;
52
52
  getPage(pageNumber: number, sortBy?: (keyof SHAPE)[], direction?: SortDirection, pageSize?: number | null, item?: Partial<SHAPE> | null): Promise<PageResult<SHAPE>>;
53
53
  getCountRaw(whereClause?: string, values?: any[], tableRef?: string): Promise<number>;
54
- getPageRaw(pageNumber: number, sortBy?: (keyof SHAPE)[], direction?: SortDirection, whereClause?: string, tableRef?: string, values?: any[], pageSize?: number | null): Promise<PageResult<SHAPE>>;
54
+ getPageRaw(pageNumber: number, sortBy?: (keyof SHAPE)[], direction?: SortDirection, whereClause?: string, tableRef?: string, values?: any[], pageSize?: number | null, searchFields?: Partial<SHAPE> | null): Promise<PageResult<SHAPE>>;
55
55
  }
package/lib/index.js CHANGED
@@ -35380,7 +35380,7 @@ var AbstractRepository = class {
35380
35380
  );
35381
35381
  return parseInt(result[0].count);
35382
35382
  }
35383
- async getPageRaw(pageNumber, sortBy = [], direction = "asc", whereClause = "", tableRef = "", values = [], pageSize = null) {
35383
+ async getPageRaw(pageNumber, sortBy = [], direction = "asc", whereClause = "", tableRef = "", values = [], pageSize = null, searchFields = null) {
35384
35384
  if (pageSize === null) {
35385
35385
  pageSize = DEFAULT_PAGE_SIZE;
35386
35386
  }
@@ -35395,6 +35395,20 @@ var AbstractRepository = class {
35395
35395
  orderByClause = `ORDER BY ${sortBy.map((a) => this.modelPropertyToSqlColumn[a]).join(",")} ${direction}`;
35396
35396
  }
35397
35397
  const offset = (pageNumber - 1) * pageSize;
35398
+ if (searchFields !== null) {
35399
+ const searchFieldsWhere = [];
35400
+ for (const [key, value] of Object.entries(searchFields)) {
35401
+ if (typeof value !== "string") {
35402
+ throw new Error(`Search field ${key} needs to be of type string`);
35403
+ }
35404
+ searchFieldsWhere.push(`${this.modelPropertyToSqlColumn[key]} LIKE $${values.length + 1}`);
35405
+ values.push(`%${value}%`);
35406
+ }
35407
+ if (whereClause.length) {
35408
+ whereClause = `${whereClause} AND`;
35409
+ }
35410
+ whereClause = `${whereClause} (${searchFieldsWhere.join(" OR ")})`;
35411
+ }
35398
35412
  const query = `
35399
35413
  SELECT *
35400
35414
  FROM ${this.tableName} ${tableRef} ${whereClause} ${orderByClause}