@squiz/db-lib 1.2.1-alpha.99 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +80 -0
- package/lib/AbstractRepository.d.ts +14 -4
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1346 -1241
- package/lib/index.js.map +4 -4
- package/package.json +8 -9
- package/src/AbstractRepository.ts +81 -6
- package/src/index.ts +2 -0
- package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
@@ -3,6 +3,86 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
5
5
|
|
6
|
+
## [1.2.2](https://gitlab.squiz.net/developer-experience/cmp/compare/v1.2.1-alpha.90...v1.2.2) (2022-09-23)
|
7
|
+
|
8
|
+
**Note:** Version bump only for package @squiz/db-lib
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
## [1.2.1](https://gitlab.squiz.net/developer-experience/cmp/compare/v1.2.1-alpha.90...v1.2.1) (2022-09-23)
|
15
|
+
|
16
|
+
**Note:** Version bump only for package @squiz/db-lib
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
## [1.2.1-alpha.107](https://gitlab.squiz.net/developer-experience/cmp/compare/v1.2.1-alpha.90...v1.2.1-alpha.107) (2022-09-21)
|
23
|
+
|
24
|
+
**Note:** Version bump only for package @squiz/db-lib
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
|
30
|
+
## [1.2.1-alpha.106](https://gitlab.squiz.net/developer-experience/cmp/compare/v1.2.1-alpha.90...v1.2.1-alpha.106) (2022-09-02)
|
31
|
+
|
32
|
+
**Note:** Version bump only for package @squiz/db-lib
|
33
|
+
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
|
38
|
+
## [1.2.1-alpha.105](https://gitlab.squiz.net/developer-experience/cmp/compare/v1.2.1-alpha.90...v1.2.1-alpha.105) (2022-08-26)
|
39
|
+
|
40
|
+
**Note:** Version bump only for package @squiz/db-lib
|
41
|
+
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
## [1.2.1-alpha.104](https://gitlab.squiz.net/developer-experience/cmp/compare/v1.2.1-alpha.90...v1.2.1-alpha.104) (2022-08-23)
|
47
|
+
|
48
|
+
**Note:** Version bump only for package @squiz/db-lib
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
## [1.2.1-alpha.103](https://gitlab.squiz.net/developer-experience/cmp/compare/v1.2.1-alpha.90...v1.2.1-alpha.103) (2022-08-23)
|
55
|
+
|
56
|
+
**Note:** Version bump only for package @squiz/db-lib
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
|
62
|
+
## [1.2.1-alpha.102](https://gitlab.squiz.net/developer-experience/cmp/compare/v1.2.1-alpha.90...v1.2.1-alpha.102) (2022-08-23)
|
63
|
+
|
64
|
+
**Note:** Version bump only for package @squiz/db-lib
|
65
|
+
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
## [1.2.1-alpha.101](https://gitlab.squiz.net/developer-experience/cmp/compare/v1.2.1-alpha.90...v1.2.1-alpha.101) (2022-08-19)
|
71
|
+
|
72
|
+
**Note:** Version bump only for package @squiz/db-lib
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
## [1.2.1-alpha.100](https://gitlab.squiz.net/developer-experience/cmp/compare/v1.2.1-alpha.90...v1.2.1-alpha.100) (2022-08-18)
|
79
|
+
|
80
|
+
**Note:** Version bump only for package @squiz/db-lib
|
81
|
+
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
|
6
86
|
## [1.2.1-alpha.99](https://gitlab.squiz.net/developer-experience/cmp/compare/v1.2.1-alpha.90...v1.2.1-alpha.99) (2022-08-18)
|
7
87
|
|
8
88
|
**Note:** Version bump only for package @squiz/db-lib
|
@@ -10,11 +10,18 @@ export interface Writer<T> {
|
|
10
10
|
delete(where: Partial<T>): Promise<number>;
|
11
11
|
}
|
12
12
|
export declare type Repository<T> = Reader<T> & Writer<T>;
|
13
|
-
export declare
|
13
|
+
export declare type PageResult<T> = {
|
14
|
+
items: T[];
|
15
|
+
totalCount: number;
|
16
|
+
pageSize: number;
|
17
|
+
};
|
18
|
+
export declare type SortDirection = 'desc' | 'asc';
|
19
|
+
export declare const DEFAULT_PAGE_SIZE = 20;
|
20
|
+
export declare abstract class AbstractRepository<T, ObjT extends T> implements Reader<T>, Writer<T> {
|
14
21
|
protected repositories: Repositories;
|
15
22
|
protected pool: Pool;
|
16
23
|
protected classRef: {
|
17
|
-
new (data?: Record<string, unknown>):
|
24
|
+
new (data?: Record<string, unknown>): ObjT;
|
18
25
|
};
|
19
26
|
protected tableName: string;
|
20
27
|
/** object where the key is the model property name amd the value is sql column name */
|
@@ -28,16 +35,19 @@ export declare abstract class AbstractRepository<T> implements Reader<T>, Writer
|
|
28
35
|
constructor(repositories: Repositories, pool: Pool, tableName: string, mapping: {
|
29
36
|
[key in keyof T]: string;
|
30
37
|
}, classRef: {
|
31
|
-
new (data?: Record<string, unknown>):
|
38
|
+
new (data?: Record<string, unknown>): ObjT;
|
32
39
|
});
|
33
40
|
protected getConnection(): Promise<PoolClient>;
|
34
|
-
create(value:
|
41
|
+
create(value: ObjT, transactionClient?: PoolClient | null): Promise<T>;
|
35
42
|
update(where: Partial<T>, newValue: Partial<T>, transactionClient?: PoolClient | null): Promise<T[]>;
|
36
43
|
delete(where: Partial<T>, transactionClient?: PoolClient | null): Promise<number>;
|
37
44
|
protected createWhereStringFromPartialModel(values: Partial<T>, initialIndex?: number): string;
|
45
|
+
protected executeQueryRaw(query: string, values: any[], transactionClient?: PoolClient | null): Promise<any[]>;
|
38
46
|
protected executeQuery(query: string, values: any[], transactionClient?: PoolClient | null): Promise<T[]>;
|
39
47
|
protected createAndHydrateModel(row: any): T;
|
40
48
|
findOne(item: Partial<T>): Promise<T | undefined>;
|
41
49
|
find(item: Partial<T>): Promise<T[]>;
|
42
50
|
findAll(): Promise<T[]>;
|
51
|
+
getCount(item?: Partial<T> | null): Promise<number>;
|
52
|
+
getPage(pageNumber: number, sortBy?: (keyof T)[], direction?: SortDirection, pageSize?: number | null, item?: Partial<T> | null): Promise<PageResult<T>>;
|
43
53
|
}
|
package/lib/index.d.ts
CHANGED