@squiz/db-lib 1.22.1-alpha.12 → 1.22.1-alpha.14

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,36 +2,36 @@
2
2
  1 info using npm@9.5.0
3
3
  2 info using node@v18.15.0
4
4
  3 timing npm:load:whichnode Completed in 1ms
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
5
+ 4 timing config:load:defaults Completed in 3ms
6
+ 5 timing config:load:file:/usr/local/lib/node_modules/npm/npmrc Completed in 1ms
7
7
  6 timing config:load:builtin Completed in 1ms
8
- 7 timing config:load:cli Completed in 1ms
9
- 8 timing config:load:env Completed in 1ms
8
+ 7 timing config:load:cli Completed in 3ms
9
+ 8 timing config:load:env Completed in 2ms
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 20ms
12
+ 11 timing config:load:project Completed in 25ms
13
13
  12 timing config:load:file:/root/.npmrc Completed in 1ms
14
- 13 timing config:load:user Completed in 2ms
15
- 14 timing config:load:file:/usr/local/etc/npmrc Completed in 0ms
16
- 15 timing config:load:global Completed in 0ms
14
+ 13 timing config:load:user Completed in 1ms
15
+ 14 timing config:load:file:/usr/local/etc/npmrc Completed in 1ms
16
+ 15 timing config:load:global Completed in 1ms
17
17
  16 timing config:load:setEnvs Completed in 1ms
18
- 17 timing config:load Completed in 29ms
19
- 18 timing npm:load:configload Completed in 29ms
20
- 19 timing npm:load:mkdirpcache Completed in 1ms
21
- 20 timing npm:load:mkdirplogs Completed in 0ms
18
+ 17 timing config:load Completed in 37ms
19
+ 18 timing npm:load:configload Completed in 37ms
20
+ 19 timing npm:load:mkdirpcache Completed in 0ms
21
+ 20 timing npm:load:mkdirplogs Completed in 1ms
22
22
  21 verbose title npm run compile
23
23
  22 verbose argv "run" "compile" "--"
24
- 23 timing npm:load:setTitle Completed in 2ms
24
+ 23 timing npm:load:setTitle Completed in 1ms
25
25
  24 timing config:load:flatten Completed in 5ms
26
26
  25 timing npm:load:display Completed in 6ms
27
- 26 verbose logfile logs-max:10 dir:/builds/developer-experience/cmp/packages/db-lib/.npm/_logs/2023-04-11T22_24_45_317Z-
28
- 27 verbose logfile /builds/developer-experience/cmp/packages/db-lib/.npm/_logs/2023-04-11T22_24_45_317Z-debug-0.log
27
+ 26 verbose logfile logs-max:10 dir:/builds/developer-experience/cmp/packages/db-lib/.npm/_logs/2023-04-12T22_45_32_644Z-
28
+ 27 verbose logfile /builds/developer-experience/cmp/packages/db-lib/.npm/_logs/2023-04-12T22_45_32_644Z-debug-0.log
29
29
  28 timing npm:load:logFile Completed in 4ms
30
30
  29 timing npm:load:timers Completed in 0ms
31
31
  30 timing npm:load:configScope Completed in 0ms
32
- 31 timing npm:load Completed in 44ms
32
+ 31 timing npm:load Completed in 50ms
33
33
  32 silly logfile done cleaning log files
34
- 33 timing command:run Completed in 2821ms
34
+ 33 timing command:run Completed in 2869ms
35
35
  34 verbose exit 0
36
- 35 timing npm Completed in 2878ms
36
+ 35 timing npm Completed in 2933ms
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}