@naturalcycles/db-lib 8.43.1 → 8.43.3
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.
|
@@ -10,7 +10,7 @@ import { CommonDaoCfg, CommonDaoCreateOptions, CommonDaoOptions, CommonDaoSaveOp
|
|
|
10
10
|
* BM = Backend model (optimized for API access)
|
|
11
11
|
* TM = Transport model (optimized to be sent over the wire)
|
|
12
12
|
*/
|
|
13
|
-
export declare class CommonDao<BM extends ObjectWithId<ID
|
|
13
|
+
export declare class CommonDao<BM extends Partial<ObjectWithId<ID>>, DBM extends ObjectWithId<ID> = Saved<BM>, TM extends AnyObject = BM, ID extends string | number = NonNullable<BM['id']>> {
|
|
14
14
|
cfg: CommonDaoCfg<BM, DBM, TM, ID>;
|
|
15
15
|
constructor(cfg: CommonDaoCfg<BM, DBM, TM, ID>);
|
|
16
16
|
create(part?: Partial<BM>, opt?: CommonDaoOptions): Saved<BM>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { CommonLogger, ErrorMode, ObjectWithId } from '@naturalcycles/js-lib';
|
|
1
|
+
import { CommonLogger, ErrorMode, ObjectWithId, Saved } from '@naturalcycles/js-lib';
|
|
2
2
|
import { AjvSchema, AjvValidationError, JoiValidationError, ObjectSchemaTyped, TransformLogProgressOptions, TransformMapOptions } from '@naturalcycles/nodejs-lib';
|
|
3
3
|
import { CommonDB } from '../common.db';
|
|
4
4
|
import { CommonDBCreateOptions, CommonDBOptions, CommonDBSaveOptions } from '../db.model';
|
|
5
|
-
export interface CommonDaoHooks<BM extends ObjectWithId<ID
|
|
5
|
+
export interface CommonDaoHooks<BM extends Partial<ObjectWithId<ID>>, DBM extends ObjectWithId<ID>, TM, ID extends string | number> {
|
|
6
6
|
createId: (obj: DBM | BM) => ID;
|
|
7
7
|
parseNaturalId: (id: ID) => Partial<DBM>;
|
|
8
8
|
beforeCreate: (bm: Partial<BM>) => Partial<BM>;
|
|
@@ -38,7 +38,7 @@ export declare enum CommonDaoLogLevel {
|
|
|
38
38
|
*/
|
|
39
39
|
DATA_FULL = 30
|
|
40
40
|
}
|
|
41
|
-
export interface CommonDaoCfg<BM extends ObjectWithId<ID
|
|
41
|
+
export interface CommonDaoCfg<BM extends Partial<ObjectWithId<ID>>, DBM extends ObjectWithId<ID> = Saved<BM>, TM = BM, ID extends string | number = string> {
|
|
42
42
|
db: CommonDB;
|
|
43
43
|
table: string;
|
|
44
44
|
/**
|
package/dist/query/dbQuery.d.ts
CHANGED
|
@@ -83,7 +83,7 @@ export declare class DBQuery<ROW extends ObjectWithId = AnyObjectWithId> {
|
|
|
83
83
|
/**
|
|
84
84
|
* DBQuery that has additional method to support Fluent API style.
|
|
85
85
|
*/
|
|
86
|
-
export declare class RunnableDBQuery<BM extends ObjectWithId<ID
|
|
86
|
+
export declare class RunnableDBQuery<BM extends Partial<ObjectWithId<ID>>, DBM extends ObjectWithId<ID> = Saved<BM>, TM extends AnyObject = BM, ID extends string | number = string> extends DBQuery<DBM> {
|
|
87
87
|
dao: CommonDao<BM, DBM, TM, ID>;
|
|
88
88
|
/**
|
|
89
89
|
* Pass `table` to override table.
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CommonLogger, ErrorMode, ObjectWithId } from '@naturalcycles/js-lib'
|
|
1
|
+
import { CommonLogger, ErrorMode, ObjectWithId, Saved } from '@naturalcycles/js-lib'
|
|
2
2
|
import {
|
|
3
3
|
AjvSchema,
|
|
4
4
|
AjvValidationError,
|
|
@@ -11,7 +11,7 @@ import { CommonDB } from '../common.db'
|
|
|
11
11
|
import { CommonDBCreateOptions, CommonDBOptions, CommonDBSaveOptions } from '../db.model'
|
|
12
12
|
|
|
13
13
|
export interface CommonDaoHooks<
|
|
14
|
-
BM extends ObjectWithId<ID
|
|
14
|
+
BM extends Partial<ObjectWithId<ID>>,
|
|
15
15
|
DBM extends ObjectWithId<ID>,
|
|
16
16
|
TM,
|
|
17
17
|
ID extends string | number,
|
|
@@ -55,8 +55,8 @@ export enum CommonDaoLogLevel {
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
export interface CommonDaoCfg<
|
|
58
|
-
BM extends ObjectWithId<ID
|
|
59
|
-
DBM extends ObjectWithId<ID> = BM
|
|
58
|
+
BM extends Partial<ObjectWithId<ID>>,
|
|
59
|
+
DBM extends ObjectWithId<ID> = Saved<BM>,
|
|
60
60
|
TM = BM,
|
|
61
61
|
ID extends string | number = string,
|
|
62
62
|
> {
|
|
@@ -68,10 +68,10 @@ const isCI = !!process.env['CI']
|
|
|
68
68
|
* TM = Transport model (optimized to be sent over the wire)
|
|
69
69
|
*/
|
|
70
70
|
export class CommonDao<
|
|
71
|
-
BM extends ObjectWithId<ID
|
|
72
|
-
DBM extends ObjectWithId<ID> = BM
|
|
71
|
+
BM extends Partial<ObjectWithId<ID>>,
|
|
72
|
+
DBM extends ObjectWithId<ID> = Saved<BM>,
|
|
73
73
|
TM extends AnyObject = BM,
|
|
74
|
-
ID extends string | number =
|
|
74
|
+
ID extends string | number = NonNullable<BM['id']>,
|
|
75
75
|
> {
|
|
76
76
|
constructor(public cfg: CommonDaoCfg<BM, DBM, TM, ID>) {
|
|
77
77
|
this.cfg = {
|
package/src/query/dbQuery.ts
CHANGED
|
@@ -225,8 +225,8 @@ export class DBQuery<ROW extends ObjectWithId = AnyObjectWithId> {
|
|
|
225
225
|
* DBQuery that has additional method to support Fluent API style.
|
|
226
226
|
*/
|
|
227
227
|
export class RunnableDBQuery<
|
|
228
|
-
BM extends ObjectWithId<ID
|
|
229
|
-
DBM extends ObjectWithId<ID> = BM
|
|
228
|
+
BM extends Partial<ObjectWithId<ID>>,
|
|
229
|
+
DBM extends ObjectWithId<ID> = Saved<BM>,
|
|
230
230
|
TM extends AnyObject = BM,
|
|
231
231
|
ID extends string | number = string,
|
|
232
232
|
> extends DBQuery<DBM> {
|