@spinajs/orm 2.0.180 → 2.0.182
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.
- package/lib/cjs/builders.d.ts +643 -643
- package/lib/cjs/builders.js +1602 -1602
- package/lib/cjs/builders.js.map +1 -1
- package/lib/cjs/converters.d.ts +34 -34
- package/lib/cjs/converters.js +104 -104
- package/lib/cjs/decorators.d.ts +152 -152
- package/lib/cjs/decorators.js +449 -449
- package/lib/cjs/dehydrators.d.ts +10 -10
- package/lib/cjs/dehydrators.js +47 -47
- package/lib/cjs/driver.d.ts +82 -82
- package/lib/cjs/driver.js +102 -102
- package/lib/cjs/driver.js.map +1 -1
- package/lib/cjs/enums.d.ts +116 -116
- package/lib/cjs/enums.js +126 -126
- package/lib/cjs/enums.js.map +1 -1
- package/lib/cjs/exceptions.d.ts +6 -6
- package/lib/cjs/exceptions.js +10 -10
- package/lib/cjs/hydrators.d.ts +19 -19
- package/lib/cjs/hydrators.js +132 -132
- package/lib/cjs/hydrators.js.map +1 -1
- package/lib/cjs/index.d.ts +17 -17
- package/lib/cjs/index.js +33 -33
- package/lib/cjs/interfaces.d.ts +921 -919
- package/lib/cjs/interfaces.d.ts.map +1 -1
- package/lib/cjs/interfaces.js +279 -279
- package/lib/cjs/interfaces.js.map +1 -1
- package/lib/cjs/middlewares.d.ts +62 -62
- package/lib/cjs/middlewares.js +258 -258
- package/lib/cjs/model.d.ts +288 -284
- package/lib/cjs/model.d.ts.map +1 -1
- package/lib/cjs/model.js +826 -810
- package/lib/cjs/model.js.map +1 -1
- package/lib/cjs/orm.d.ts +61 -61
- package/lib/cjs/orm.js +333 -333
- package/lib/cjs/orm.js.map +1 -1
- package/lib/cjs/relation-objects.d.ts +108 -108
- package/lib/cjs/relation-objects.js +221 -221
- package/lib/cjs/relations.d.ts +61 -61
- package/lib/cjs/relations.js +194 -194
- package/lib/cjs/relations.js.map +1 -1
- package/lib/cjs/statements.d.ts +143 -143
- package/lib/cjs/statements.js +309 -309
- package/lib/cjs/statements.js.map +1 -1
- package/lib/cjs/types.d.ts +32 -32
- package/lib/cjs/types.js +2 -2
- package/lib/cjs/wrappers.d.ts +5 -5
- package/lib/cjs/wrappers.js +12 -12
- package/lib/mjs/builders.d.ts +643 -643
- package/lib/mjs/builders.js +1594 -1594
- package/lib/mjs/builders.js.map +1 -1
- package/lib/mjs/converters.d.ts +34 -34
- package/lib/mjs/converters.js +96 -96
- package/lib/mjs/decorators.d.ts +152 -152
- package/lib/mjs/decorators.js +422 -422
- package/lib/mjs/dehydrators.d.ts +10 -10
- package/lib/mjs/dehydrators.js +41 -41
- package/lib/mjs/driver.d.ts +82 -82
- package/lib/mjs/driver.js +98 -98
- package/lib/mjs/driver.js.map +1 -1
- package/lib/mjs/enums.d.ts +116 -116
- package/lib/mjs/enums.js +123 -123
- package/lib/mjs/enums.js.map +1 -1
- package/lib/mjs/exceptions.d.ts +6 -6
- package/lib/mjs/exceptions.js +6 -6
- package/lib/mjs/hydrators.d.ts +19 -19
- package/lib/mjs/hydrators.js +128 -128
- package/lib/mjs/hydrators.js.map +1 -1
- package/lib/mjs/index.d.ts +17 -17
- package/lib/mjs/index.js +17 -17
- package/lib/mjs/interfaces.d.ts +921 -919
- package/lib/mjs/interfaces.d.ts.map +1 -1
- package/lib/mjs/interfaces.js +267 -267
- package/lib/mjs/interfaces.js.map +1 -1
- package/lib/mjs/middlewares.d.ts +62 -62
- package/lib/mjs/middlewares.js +249 -249
- package/lib/mjs/model.d.ts +288 -284
- package/lib/mjs/model.d.ts.map +1 -1
- package/lib/mjs/model.js +816 -800
- package/lib/mjs/model.js.map +1 -1
- package/lib/mjs/orm.d.ts +61 -61
- package/lib/mjs/orm.js +326 -326
- package/lib/mjs/orm.js.map +1 -1
- package/lib/mjs/relation-objects.d.ts +108 -108
- package/lib/mjs/relation-objects.js +211 -211
- package/lib/mjs/relations.d.ts +61 -61
- package/lib/mjs/relations.js +191 -191
- package/lib/mjs/relations.js.map +1 -1
- package/lib/mjs/statements.d.ts +143 -143
- package/lib/mjs/statements.js +301 -301
- package/lib/mjs/statements.js.map +1 -1
- package/lib/mjs/types.d.ts +32 -32
- package/lib/mjs/types.js +1 -1
- package/lib/mjs/wrappers.d.ts +5 -5
- package/lib/mjs/wrappers.js +9 -9
- package/lib/tsconfig.cjs.tsbuildinfo +1 -1
- package/lib/tsconfig.mjs.tsbuildinfo +1 -1
- package/package.json +5 -5
package/lib/cjs/decorators.d.ts
CHANGED
|
@@ -1,153 +1,153 @@
|
|
|
1
|
-
import { Constructor, IContainer } from '@spinajs/di';
|
|
2
|
-
import { IModelDescriptor, IRelationDescriptor, IDiscriminationEntry } from './interfaces.js';
|
|
3
|
-
import 'reflect-metadata';
|
|
4
|
-
import { ModelBase } from './model.js';
|
|
5
|
-
import { Relation } from './relation-objects.js';
|
|
6
|
-
export declare const MODEL_DESCTRIPTION_SYMBOL: unique symbol;
|
|
7
|
-
export declare const MIGRATION_DESCRIPTION_SYMBOL: unique symbol;
|
|
8
|
-
/**
|
|
9
|
-
* Helper func to create model metadata
|
|
10
|
-
*/
|
|
11
|
-
export declare function extractDecoratorDescriptor(callback: (model: IModelDescriptor, target: any, propertyKey: symbol | string, indexOrDescriptor: number | PropertyDescriptor) => void, base?: boolean): any;
|
|
12
|
-
/**
|
|
13
|
-
* Sets migration option
|
|
14
|
-
*
|
|
15
|
-
* @param connection - connection name, must exists in configuration file
|
|
16
|
-
*/
|
|
17
|
-
export declare function Migration(connection: string): (target: any) => void;
|
|
18
|
-
/**
|
|
19
|
-
* Connection model decorator, assigns connection to model
|
|
20
|
-
*
|
|
21
|
-
* @param name - connection name, must be avaible in db config
|
|
22
|
-
*/
|
|
23
|
-
export declare function Connection(name: string): any;
|
|
24
|
-
/**
|
|
25
|
-
* TableName model decorator, assigns table from database to model
|
|
26
|
-
*
|
|
27
|
-
* @param name - table name in database that is referred by this model
|
|
28
|
-
*/
|
|
29
|
-
export declare function Model(tableName: string): any;
|
|
30
|
-
/**
|
|
31
|
-
* Set create timestamps feature to model. Proper columns must be avaible in database table.
|
|
32
|
-
* It allow to track creation times & changes to model
|
|
33
|
-
*/
|
|
34
|
-
export declare function CreatedAt(): any;
|
|
35
|
-
/**
|
|
36
|
-
* Set update timestamps feature to model. Proper columns must be avaible in database table.
|
|
37
|
-
* It allow to track creation times & changes to model
|
|
38
|
-
*/
|
|
39
|
-
export declare function UpdatedAt(): any;
|
|
40
|
-
/**
|
|
41
|
-
* Sets soft delete feature to model. Soft delete dont delete model, but sets deletion date and hides from
|
|
42
|
-
* select result by default.
|
|
43
|
-
*/
|
|
44
|
-
export declare function SoftDelete(): any;
|
|
45
|
-
/**
|
|
46
|
-
* Enable archive mode for model. If enabled all changes creates new instance in DB and old have set archived field
|
|
47
|
-
* and gets attached to new model. It enabled to track changes to model in DB and also preserve data in relations.
|
|
48
|
-
*
|
|
49
|
-
*/
|
|
50
|
-
export declare function Archived(): any;
|
|
51
|
-
/**
|
|
52
|
-
* Makrs field as primary key
|
|
53
|
-
*/
|
|
54
|
-
export declare function Primary(): any;
|
|
55
|
-
/**
|
|
56
|
-
* Marks columns as UUID. Column will be generated ad creation
|
|
57
|
-
*/
|
|
58
|
-
export declare function Ignore(): any;
|
|
59
|
-
/**
|
|
60
|
-
* Marks columns as UUID. Column will be generated ad creation
|
|
61
|
-
*/
|
|
62
|
-
export declare function Uuid(): any;
|
|
63
|
-
export declare function JunctionTable(): any;
|
|
64
|
-
/**
|
|
65
|
-
*
|
|
66
|
-
* Marks model to have discrimination map.
|
|
67
|
-
*
|
|
68
|
-
* @param fieldName - db field name to look for
|
|
69
|
-
* @param discriminationMap - field - model mapping
|
|
70
|
-
*/
|
|
71
|
-
export declare function DiscriminationMap(fieldName: string, discriminationMap: IDiscriminationEntry[]): any;
|
|
72
|
-
/**
|
|
73
|
-
* Marks relation as recursive. When relation is populated it loads all to the top
|
|
74
|
-
*
|
|
75
|
-
*/
|
|
76
|
-
export declare function Recursive(): any;
|
|
77
|
-
export interface IForwardReference<T = any> {
|
|
78
|
-
forwardRef: T;
|
|
79
|
-
}
|
|
80
|
-
export declare const forwardRef: (fn: () => any) => IForwardReference;
|
|
81
|
-
/**
|
|
82
|
-
* Creates one to one relation with target model.
|
|
83
|
-
*
|
|
84
|
-
* @param foreignKey - foreign key name in db, defaults to lowercase property name with _id suffix eg. owner_id
|
|
85
|
-
* @param primaryKey - primary key in related model, defaults to primary key taken from db
|
|
86
|
-
*/
|
|
87
|
-
export declare function BelongsTo(targetModel: Constructor<ModelBase> | string, foreignKey?: string, primaryKey?: string): any;
|
|
88
|
-
/**
|
|
89
|
-
* Creates one to one relation with target model.
|
|
90
|
-
*
|
|
91
|
-
* @param foreignKey - foreign key name in db, defaults to lowercase property name with _id suffix eg. owner_id
|
|
92
|
-
* @param primaryKey - primary key in related model, defaults to primary key taken from db
|
|
93
|
-
*/
|
|
94
|
-
export declare function ForwardBelongsTo(forwardRef: IForwardReference, foreignKey?: string, primaryKey?: string): any;
|
|
95
|
-
export interface IHasManyDecoratorOptions {
|
|
96
|
-
foreignKey?: string;
|
|
97
|
-
primaryKey?: string;
|
|
98
|
-
/**
|
|
99
|
-
* Relation factory, sometimes we dont want to create standard relation object.
|
|
100
|
-
* When creating object and specific relation is created via this factory
|
|
101
|
-
*/
|
|
102
|
-
factory?: (owner: ModelBase, relation: IRelationDescriptor, container: IContainer) => Relation<ModelBase<unknown>, ModelBase<unknown>>;
|
|
103
|
-
/**
|
|
104
|
-
* sometimes we dont want to create standard relation object, so we create type
|
|
105
|
-
* that is passed in this property
|
|
106
|
-
*/
|
|
107
|
-
type?: Constructor<Relation<ModelBase<unknown>, ModelBase<unknown>>>;
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Creates one to many relation with target model.
|
|
111
|
-
*
|
|
112
|
-
* @param targetModel - due to limitations of metadata reflection api in typescript target model mus be set explicitly
|
|
113
|
-
* @param foreignKey - foreign key name in db, defaults to lowercase property name with _id suffix eg. owner_id
|
|
114
|
-
* @param primaryKey - primary key in source table defaults to lowercase property name with _id suffix eg. owner_id
|
|
115
|
-
*
|
|
116
|
-
*/
|
|
117
|
-
export declare function HasMany(targetModel: Constructor<ModelBase> | string, options?: IHasManyDecoratorOptions): any;
|
|
118
|
-
export declare function Historical(targetModel: Constructor<ModelBase>): any;
|
|
119
|
-
/**
|
|
120
|
-
* Creates many to many relation with separate join table
|
|
121
|
-
*
|
|
122
|
-
* @param junctionModel - model for junction table
|
|
123
|
-
* @param targetModel - model for related data
|
|
124
|
-
* @param targetModelPKey - target model primary key name
|
|
125
|
-
* @param sourceModelPKey - source model primary key name
|
|
126
|
-
* @param junctionModelTargetPk - junction table target primary key name ( foreign key for target model )
|
|
127
|
-
* @param junctionModelSourcePk - junction table source primary key name ( foreign key for source model )
|
|
128
|
-
*/
|
|
129
|
-
export declare function HasManyToMany(junctionModel: Constructor<ModelBase>, targetModel: Constructor<ModelBase> | string, targetModelPKey?: string, sourceModelPKey?: string, junctionModelTargetPk?: string, junctionModelSourcePk?: string): any;
|
|
130
|
-
/**
|
|
131
|
-
* Mark field as datetime type. It will ensure that conversion to & from DB is valid, eg. sqlite DB
|
|
132
|
-
* saves datetime as TEXT and ISO8601 strings
|
|
133
|
-
*/
|
|
134
|
-
export declare function DateTime(): any;
|
|
135
|
-
/**
|
|
136
|
-
* Converts data in db to json object. Column type in DB should be STRING.
|
|
137
|
-
* DO not use this decorator for use of native DB JSON implementation.
|
|
138
|
-
* ORM will detect automatically if field is native JSON DB type.
|
|
139
|
-
*/
|
|
140
|
-
export declare function Json(): any;
|
|
141
|
-
/**
|
|
142
|
-
*
|
|
143
|
-
* Universal converter that guess whitch type to return. Usefull in tables that holds as text different values
|
|
144
|
-
* eg. metadata table
|
|
145
|
-
*
|
|
146
|
-
* @param typeColumn - type column that defines final type of value
|
|
147
|
-
*/
|
|
148
|
-
export declare function UniversalConverter(typeColumn: string): any;
|
|
149
|
-
/**
|
|
150
|
-
* Mark field as SET type. It will ensure that conversion to & from DB is valid, eg. to emulate field type SET in sqlite
|
|
151
|
-
*/
|
|
152
|
-
export declare function Set(): any;
|
|
1
|
+
import { Constructor, IContainer } from '@spinajs/di';
|
|
2
|
+
import { IModelDescriptor, IRelationDescriptor, IDiscriminationEntry } from './interfaces.js';
|
|
3
|
+
import 'reflect-metadata';
|
|
4
|
+
import { ModelBase } from './model.js';
|
|
5
|
+
import { Relation } from './relation-objects.js';
|
|
6
|
+
export declare const MODEL_DESCTRIPTION_SYMBOL: unique symbol;
|
|
7
|
+
export declare const MIGRATION_DESCRIPTION_SYMBOL: unique symbol;
|
|
8
|
+
/**
|
|
9
|
+
* Helper func to create model metadata
|
|
10
|
+
*/
|
|
11
|
+
export declare function extractDecoratorDescriptor(callback: (model: IModelDescriptor, target: any, propertyKey: symbol | string, indexOrDescriptor: number | PropertyDescriptor) => void, base?: boolean): any;
|
|
12
|
+
/**
|
|
13
|
+
* Sets migration option
|
|
14
|
+
*
|
|
15
|
+
* @param connection - connection name, must exists in configuration file
|
|
16
|
+
*/
|
|
17
|
+
export declare function Migration(connection: string): (target: any) => void;
|
|
18
|
+
/**
|
|
19
|
+
* Connection model decorator, assigns connection to model
|
|
20
|
+
*
|
|
21
|
+
* @param name - connection name, must be avaible in db config
|
|
22
|
+
*/
|
|
23
|
+
export declare function Connection(name: string): any;
|
|
24
|
+
/**
|
|
25
|
+
* TableName model decorator, assigns table from database to model
|
|
26
|
+
*
|
|
27
|
+
* @param name - table name in database that is referred by this model
|
|
28
|
+
*/
|
|
29
|
+
export declare function Model(tableName: string): any;
|
|
30
|
+
/**
|
|
31
|
+
* Set create timestamps feature to model. Proper columns must be avaible in database table.
|
|
32
|
+
* It allow to track creation times & changes to model
|
|
33
|
+
*/
|
|
34
|
+
export declare function CreatedAt(): any;
|
|
35
|
+
/**
|
|
36
|
+
* Set update timestamps feature to model. Proper columns must be avaible in database table.
|
|
37
|
+
* It allow to track creation times & changes to model
|
|
38
|
+
*/
|
|
39
|
+
export declare function UpdatedAt(): any;
|
|
40
|
+
/**
|
|
41
|
+
* Sets soft delete feature to model. Soft delete dont delete model, but sets deletion date and hides from
|
|
42
|
+
* select result by default.
|
|
43
|
+
*/
|
|
44
|
+
export declare function SoftDelete(): any;
|
|
45
|
+
/**
|
|
46
|
+
* Enable archive mode for model. If enabled all changes creates new instance in DB and old have set archived field
|
|
47
|
+
* and gets attached to new model. It enabled to track changes to model in DB and also preserve data in relations.
|
|
48
|
+
*
|
|
49
|
+
*/
|
|
50
|
+
export declare function Archived(): any;
|
|
51
|
+
/**
|
|
52
|
+
* Makrs field as primary key
|
|
53
|
+
*/
|
|
54
|
+
export declare function Primary(): any;
|
|
55
|
+
/**
|
|
56
|
+
* Marks columns as UUID. Column will be generated ad creation
|
|
57
|
+
*/
|
|
58
|
+
export declare function Ignore(): any;
|
|
59
|
+
/**
|
|
60
|
+
* Marks columns as UUID. Column will be generated ad creation
|
|
61
|
+
*/
|
|
62
|
+
export declare function Uuid(): any;
|
|
63
|
+
export declare function JunctionTable(): any;
|
|
64
|
+
/**
|
|
65
|
+
*
|
|
66
|
+
* Marks model to have discrimination map.
|
|
67
|
+
*
|
|
68
|
+
* @param fieldName - db field name to look for
|
|
69
|
+
* @param discriminationMap - field - model mapping
|
|
70
|
+
*/
|
|
71
|
+
export declare function DiscriminationMap(fieldName: string, discriminationMap: IDiscriminationEntry[]): any;
|
|
72
|
+
/**
|
|
73
|
+
* Marks relation as recursive. When relation is populated it loads all to the top
|
|
74
|
+
*
|
|
75
|
+
*/
|
|
76
|
+
export declare function Recursive(): any;
|
|
77
|
+
export interface IForwardReference<T = any> {
|
|
78
|
+
forwardRef: T;
|
|
79
|
+
}
|
|
80
|
+
export declare const forwardRef: (fn: () => any) => IForwardReference;
|
|
81
|
+
/**
|
|
82
|
+
* Creates one to one relation with target model.
|
|
83
|
+
*
|
|
84
|
+
* @param foreignKey - foreign key name in db, defaults to lowercase property name with _id suffix eg. owner_id
|
|
85
|
+
* @param primaryKey - primary key in related model, defaults to primary key taken from db
|
|
86
|
+
*/
|
|
87
|
+
export declare function BelongsTo(targetModel: Constructor<ModelBase> | string, foreignKey?: string, primaryKey?: string): any;
|
|
88
|
+
/**
|
|
89
|
+
* Creates one to one relation with target model.
|
|
90
|
+
*
|
|
91
|
+
* @param foreignKey - foreign key name in db, defaults to lowercase property name with _id suffix eg. owner_id
|
|
92
|
+
* @param primaryKey - primary key in related model, defaults to primary key taken from db
|
|
93
|
+
*/
|
|
94
|
+
export declare function ForwardBelongsTo(forwardRef: IForwardReference, foreignKey?: string, primaryKey?: string): any;
|
|
95
|
+
export interface IHasManyDecoratorOptions {
|
|
96
|
+
foreignKey?: string;
|
|
97
|
+
primaryKey?: string;
|
|
98
|
+
/**
|
|
99
|
+
* Relation factory, sometimes we dont want to create standard relation object.
|
|
100
|
+
* When creating object and specific relation is created via this factory
|
|
101
|
+
*/
|
|
102
|
+
factory?: (owner: ModelBase, relation: IRelationDescriptor, container: IContainer) => Relation<ModelBase<unknown>, ModelBase<unknown>>;
|
|
103
|
+
/**
|
|
104
|
+
* sometimes we dont want to create standard relation object, so we create type
|
|
105
|
+
* that is passed in this property
|
|
106
|
+
*/
|
|
107
|
+
type?: Constructor<Relation<ModelBase<unknown>, ModelBase<unknown>>>;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Creates one to many relation with target model.
|
|
111
|
+
*
|
|
112
|
+
* @param targetModel - due to limitations of metadata reflection api in typescript target model mus be set explicitly
|
|
113
|
+
* @param foreignKey - foreign key name in db, defaults to lowercase property name with _id suffix eg. owner_id
|
|
114
|
+
* @param primaryKey - primary key in source table defaults to lowercase property name with _id suffix eg. owner_id
|
|
115
|
+
*
|
|
116
|
+
*/
|
|
117
|
+
export declare function HasMany(targetModel: Constructor<ModelBase> | string, options?: IHasManyDecoratorOptions): any;
|
|
118
|
+
export declare function Historical(targetModel: Constructor<ModelBase>): any;
|
|
119
|
+
/**
|
|
120
|
+
* Creates many to many relation with separate join table
|
|
121
|
+
*
|
|
122
|
+
* @param junctionModel - model for junction table
|
|
123
|
+
* @param targetModel - model for related data
|
|
124
|
+
* @param targetModelPKey - target model primary key name
|
|
125
|
+
* @param sourceModelPKey - source model primary key name
|
|
126
|
+
* @param junctionModelTargetPk - junction table target primary key name ( foreign key for target model )
|
|
127
|
+
* @param junctionModelSourcePk - junction table source primary key name ( foreign key for source model )
|
|
128
|
+
*/
|
|
129
|
+
export declare function HasManyToMany(junctionModel: Constructor<ModelBase>, targetModel: Constructor<ModelBase> | string, targetModelPKey?: string, sourceModelPKey?: string, junctionModelTargetPk?: string, junctionModelSourcePk?: string): any;
|
|
130
|
+
/**
|
|
131
|
+
* Mark field as datetime type. It will ensure that conversion to & from DB is valid, eg. sqlite DB
|
|
132
|
+
* saves datetime as TEXT and ISO8601 strings
|
|
133
|
+
*/
|
|
134
|
+
export declare function DateTime(): any;
|
|
135
|
+
/**
|
|
136
|
+
* Converts data in db to json object. Column type in DB should be STRING.
|
|
137
|
+
* DO not use this decorator for use of native DB JSON implementation.
|
|
138
|
+
* ORM will detect automatically if field is native JSON DB type.
|
|
139
|
+
*/
|
|
140
|
+
export declare function Json(): any;
|
|
141
|
+
/**
|
|
142
|
+
*
|
|
143
|
+
* Universal converter that guess whitch type to return. Usefull in tables that holds as text different values
|
|
144
|
+
* eg. metadata table
|
|
145
|
+
*
|
|
146
|
+
* @param typeColumn - type column that defines final type of value
|
|
147
|
+
*/
|
|
148
|
+
export declare function UniversalConverter(typeColumn: string): any;
|
|
149
|
+
/**
|
|
150
|
+
* Mark field as SET type. It will ensure that conversion to & from DB is valid, eg. to emulate field type SET in sqlite
|
|
151
|
+
*/
|
|
152
|
+
export declare function Set(): any;
|
|
153
153
|
//# sourceMappingURL=decorators.d.ts.map
|