@squiz/db-lib 1.22.1-alpha.8 → 1.27.1-alpha.1
Sign up to get free protection for your applications and to get access to all the features.
- package/.npm/_logs/{2023-04-04T12_43_28_571Z-debug-0.log → 2023-04-13T05_12_02_758Z-debug-0.log} +12 -12
- package/lib/AbstractRepository.d.ts +1 -1
- package/lib/index.js +15 -1
- package/lib/index.js.map +2 -2
- package/package.json +3 -3
- package/src/AbstractRepository.ts +16 -0
- package/tsconfig.tsbuildinfo +1 -1
package/.npm/_logs/{2023-04-04T12_43_28_571Z-debug-0.log → 2023-04-13T05_12_02_758Z-debug-0.log}
RENAMED
@@ -1,37 +1,37 @@
|
|
1
1
|
0 verbose cli /usr/local/bin/node /usr/local/bin/npm
|
2
2
|
1 info using npm@9.5.0
|
3
3
|
2 info using node@v18.15.0
|
4
|
-
3 timing npm:load:whichnode Completed in
|
4
|
+
3 timing npm:load:whichnode Completed in 1ms
|
5
5
|
4 timing config:load:defaults Completed in 2ms
|
6
6
|
5 timing config:load:file:/usr/local/lib/node_modules/npm/npmrc Completed in 0ms
|
7
|
-
6 timing config:load:builtin Completed in
|
7
|
+
6 timing config:load:builtin Completed in 0ms
|
8
8
|
7 timing config:load:cli Completed in 1ms
|
9
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
|
12
|
+
11 timing config:load:project Completed in 20ms
|
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
|
-
15 timing config:load:global Completed in
|
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
|
19
|
-
18 timing npm:load:configload Completed in
|
20
|
-
19 timing npm:load:mkdirpcache Completed in
|
18
|
+
17 timing config:load Completed in 28ms
|
19
|
+
18 timing npm:load:configload Completed in 29ms
|
20
|
+
19 timing npm:load:mkdirpcache Completed in 1ms
|
21
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
24
|
23 timing npm:load:setTitle Completed in 2ms
|
25
25
|
24 timing config:load:flatten Completed in 4ms
|
26
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-
|
28
|
-
27 verbose logfile /builds/developer-experience/cmp/packages/db-lib/.npm/_logs/2023-04-
|
27
|
+
26 verbose logfile logs-max:10 dir:/builds/developer-experience/cmp/packages/db-lib/.npm/_logs/2023-04-13T05_12_02_758Z-
|
28
|
+
27 verbose logfile /builds/developer-experience/cmp/packages/db-lib/.npm/_logs/2023-04-13T05_12_02_758Z-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
|
32
|
+
31 timing npm:load Completed in 42ms
|
33
33
|
32 silly logfile done cleaning log files
|
34
|
-
33 timing command:run Completed in
|
34
|
+
33 timing command:run Completed in 2683ms
|
35
35
|
34 verbose exit 0
|
36
|
-
35 timing npm Completed in
|
36
|
+
35 timing npm Completed in 2738ms
|
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}
|