@mikro-orm/core 7.0.2-dev.8 → 7.0.2
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/EntityManager.d.ts +883 -579
- package/EntityManager.js +1897 -1865
- package/MikroORM.d.ts +103 -72
- package/MikroORM.js +178 -177
- package/README.md +128 -294
- package/cache/CacheAdapter.d.ts +38 -36
- package/cache/FileCacheAdapter.d.ts +30 -24
- package/cache/FileCacheAdapter.js +80 -78
- package/cache/GeneratedCacheAdapter.d.ts +19 -20
- package/cache/GeneratedCacheAdapter.js +31 -30
- package/cache/MemoryCacheAdapter.d.ts +19 -20
- package/cache/MemoryCacheAdapter.js +36 -36
- package/cache/NullCacheAdapter.d.ts +17 -16
- package/cache/NullCacheAdapter.js +25 -24
- package/connections/Connection.d.ts +99 -75
- package/connections/Connection.js +166 -160
- package/drivers/DatabaseDriver.d.ts +187 -69
- package/drivers/DatabaseDriver.js +451 -432
- package/drivers/IDatabaseDriver.d.ts +464 -281
- package/drivers/IDatabaseDriver.js +1 -0
- package/entity/BaseEntity.d.ts +121 -73
- package/entity/BaseEntity.js +44 -33
- package/entity/Collection.d.ts +216 -157
- package/entity/Collection.js +728 -707
- package/entity/EntityAssigner.d.ts +90 -76
- package/entity/EntityAssigner.js +232 -229
- package/entity/EntityFactory.d.ts +68 -40
- package/entity/EntityFactory.js +427 -366
- package/entity/EntityHelper.d.ts +34 -22
- package/entity/EntityHelper.js +280 -267
- package/entity/EntityIdentifier.d.ts +4 -4
- package/entity/EntityIdentifier.js +10 -10
- package/entity/EntityLoader.d.ts +105 -56
- package/entity/EntityLoader.js +754 -722
- package/entity/EntityRepository.d.ts +317 -200
- package/entity/EntityRepository.js +214 -212
- package/entity/PolymorphicRef.d.ts +5 -5
- package/entity/PolymorphicRef.js +10 -10
- package/entity/Reference.d.ts +130 -66
- package/entity/Reference.js +280 -260
- package/entity/WrappedEntity.d.ts +116 -53
- package/entity/WrappedEntity.js +169 -147
- package/entity/defineEntity.d.ts +1290 -614
- package/entity/defineEntity.js +521 -511
- package/entity/utils.d.ts +13 -3
- package/entity/utils.js +71 -73
- package/entity/validators.js +43 -43
- package/entity/wrap.js +8 -8
- package/enums.d.ts +275 -138
- package/enums.js +268 -137
- package/errors.d.ts +120 -72
- package/errors.js +356 -253
- package/events/EventManager.d.ts +27 -10
- package/events/EventManager.js +80 -73
- package/events/EventSubscriber.d.ts +33 -29
- package/events/TransactionEventBroadcaster.d.ts +16 -7
- package/events/TransactionEventBroadcaster.js +15 -13
- package/exceptions.d.ts +23 -40
- package/exceptions.js +35 -52
- package/hydration/Hydrator.d.ts +43 -16
- package/hydration/Hydrator.js +44 -42
- package/hydration/ObjectHydrator.d.ts +51 -17
- package/hydration/ObjectHydrator.js +480 -416
- package/index.d.ts +116 -2
- package/index.js +10 -1
- package/logging/DefaultLogger.d.ts +35 -30
- package/logging/DefaultLogger.js +87 -84
- package/logging/Logger.d.ts +45 -40
- package/logging/SimpleLogger.d.ts +13 -11
- package/logging/SimpleLogger.js +22 -22
- package/logging/colors.d.ts +6 -6
- package/logging/colors.js +11 -10
- package/logging/inspect.js +7 -7
- package/metadata/EntitySchema.d.ts +214 -108
- package/metadata/EntitySchema.js +398 -379
- package/metadata/MetadataDiscovery.d.ts +115 -111
- package/metadata/MetadataDiscovery.js +1948 -1857
- package/metadata/MetadataProvider.d.ts +25 -14
- package/metadata/MetadataProvider.js +83 -77
- package/metadata/MetadataStorage.d.ts +39 -19
- package/metadata/MetadataStorage.js +119 -106
- package/metadata/MetadataValidator.d.ts +39 -39
- package/metadata/MetadataValidator.js +381 -338
- package/metadata/discover-entities.d.ts +5 -2
- package/metadata/discover-entities.js +27 -27
- package/metadata/types.d.ts +615 -531
- package/naming-strategy/AbstractNamingStrategy.d.ts +55 -39
- package/naming-strategy/AbstractNamingStrategy.js +91 -85
- package/naming-strategy/EntityCaseNamingStrategy.d.ts +6 -6
- package/naming-strategy/EntityCaseNamingStrategy.js +22 -22
- package/naming-strategy/MongoNamingStrategy.d.ts +7 -6
- package/naming-strategy/MongoNamingStrategy.js +19 -18
- package/naming-strategy/NamingStrategy.d.ts +109 -99
- package/naming-strategy/UnderscoreNamingStrategy.d.ts +8 -7
- package/naming-strategy/UnderscoreNamingStrategy.js +22 -21
- package/not-supported.js +7 -4
- package/package.json +1 -1
- package/platforms/ExceptionConverter.d.ts +2 -1
- package/platforms/ExceptionConverter.js +5 -4
- package/platforms/Platform.d.ts +310 -236
- package/platforms/Platform.js +661 -573
- package/serialization/EntitySerializer.d.ts +49 -25
- package/serialization/EntitySerializer.js +224 -216
- package/serialization/EntityTransformer.d.ts +11 -5
- package/serialization/EntityTransformer.js +220 -216
- package/serialization/SerializationContext.d.ts +27 -18
- package/serialization/SerializationContext.js +105 -100
- package/types/ArrayType.d.ts +9 -8
- package/types/ArrayType.js +34 -33
- package/types/BigIntType.d.ts +17 -10
- package/types/BigIntType.js +37 -37
- package/types/BlobType.d.ts +4 -3
- package/types/BlobType.js +14 -13
- package/types/BooleanType.d.ts +5 -4
- package/types/BooleanType.js +13 -12
- package/types/CharacterType.d.ts +3 -2
- package/types/CharacterType.js +7 -6
- package/types/DateTimeType.d.ts +6 -5
- package/types/DateTimeType.js +16 -15
- package/types/DateType.d.ts +6 -5
- package/types/DateType.js +16 -15
- package/types/DecimalType.d.ts +7 -7
- package/types/DecimalType.js +26 -26
- package/types/DoubleType.d.ts +3 -3
- package/types/DoubleType.js +12 -12
- package/types/EnumArrayType.d.ts +6 -5
- package/types/EnumArrayType.js +25 -24
- package/types/EnumType.d.ts +4 -3
- package/types/EnumType.js +12 -11
- package/types/FloatType.d.ts +4 -3
- package/types/FloatType.js +10 -9
- package/types/IntegerType.d.ts +4 -3
- package/types/IntegerType.js +10 -9
- package/types/IntervalType.d.ts +5 -4
- package/types/IntervalType.js +13 -12
- package/types/JsonType.d.ts +9 -8
- package/types/JsonType.js +33 -32
- package/types/MediumIntType.d.ts +2 -1
- package/types/MediumIntType.js +4 -3
- package/types/SmallIntType.d.ts +4 -3
- package/types/SmallIntType.js +10 -9
- package/types/StringType.d.ts +5 -4
- package/types/StringType.js +13 -12
- package/types/TextType.d.ts +4 -3
- package/types/TextType.js +10 -9
- package/types/TimeType.d.ts +6 -5
- package/types/TimeType.js +18 -17
- package/types/TinyIntType.d.ts +4 -3
- package/types/TinyIntType.js +11 -10
- package/types/Type.d.ts +88 -73
- package/types/Type.js +85 -74
- package/types/Uint8ArrayType.d.ts +5 -4
- package/types/Uint8ArrayType.js +22 -21
- package/types/UnknownType.d.ts +5 -4
- package/types/UnknownType.js +13 -12
- package/types/UuidType.d.ts +6 -5
- package/types/UuidType.js +20 -19
- package/types/index.d.ts +77 -49
- package/types/index.js +64 -26
- package/typings.d.ts +1388 -729
- package/typings.js +255 -231
- package/unit-of-work/ChangeSet.d.ts +28 -24
- package/unit-of-work/ChangeSet.js +58 -54
- package/unit-of-work/ChangeSetComputer.d.ts +13 -11
- package/unit-of-work/ChangeSetComputer.js +180 -159
- package/unit-of-work/ChangeSetPersister.d.ts +64 -41
- package/unit-of-work/ChangeSetPersister.js +443 -418
- package/unit-of-work/CommitOrderCalculator.d.ts +40 -40
- package/unit-of-work/CommitOrderCalculator.js +89 -88
- package/unit-of-work/IdentityMap.d.ts +32 -25
- package/unit-of-work/IdentityMap.js +106 -99
- package/unit-of-work/UnitOfWork.d.ts +182 -127
- package/unit-of-work/UnitOfWork.js +1201 -1169
- package/utils/AbstractMigrator.d.ts +111 -91
- package/utils/AbstractMigrator.js +275 -275
- package/utils/AbstractSchemaGenerator.d.ts +43 -34
- package/utils/AbstractSchemaGenerator.js +121 -122
- package/utils/AsyncContext.d.ts +3 -3
- package/utils/AsyncContext.js +34 -35
- package/utils/Configuration.d.ts +853 -801
- package/utils/Configuration.js +360 -337
- package/utils/Cursor.d.ts +40 -22
- package/utils/Cursor.js +135 -127
- package/utils/DataloaderUtils.d.ts +58 -43
- package/utils/DataloaderUtils.js +203 -198
- package/utils/EntityComparator.d.ts +99 -80
- package/utils/EntityComparator.js +825 -727
- package/utils/NullHighlighter.d.ts +2 -1
- package/utils/NullHighlighter.js +4 -3
- package/utils/QueryHelper.d.ts +79 -51
- package/utils/QueryHelper.js +372 -361
- package/utils/RawQueryFragment.d.ts +54 -28
- package/utils/RawQueryFragment.js +110 -99
- package/utils/RequestContext.d.ts +33 -32
- package/utils/RequestContext.js +52 -53
- package/utils/TransactionContext.d.ts +17 -16
- package/utils/TransactionContext.js +28 -27
- package/utils/TransactionManager.d.ts +58 -58
- package/utils/TransactionManager.js +199 -197
- package/utils/Utils.d.ts +210 -145
- package/utils/Utils.js +820 -813
- package/utils/clone.js +104 -113
- package/utils/env-vars.js +90 -88
- package/utils/fs-utils.d.ts +15 -15
- package/utils/fs-utils.js +180 -181
- package/utils/upsert-utils.d.ts +20 -5
- package/utils/upsert-utils.js +114 -116
package/entity/defineEntity.d.ts
CHANGED
|
@@ -1,16 +1,68 @@
|
|
|
1
1
|
import type { EntityManager } from '../EntityManager.js';
|
|
2
|
-
import type {
|
|
3
|
-
|
|
2
|
+
import type {
|
|
3
|
+
ColumnType,
|
|
4
|
+
PropertyOptions,
|
|
5
|
+
ReferenceOptions,
|
|
6
|
+
EnumOptions,
|
|
7
|
+
EmbeddedOptions,
|
|
8
|
+
ManyToOneOptions,
|
|
9
|
+
OneToManyOptions,
|
|
10
|
+
OneToOneOptions,
|
|
11
|
+
ManyToManyOptions,
|
|
12
|
+
} from '../metadata/types.js';
|
|
13
|
+
import type {
|
|
14
|
+
AnyString,
|
|
15
|
+
GeneratedColumnCallback,
|
|
16
|
+
Constructor,
|
|
17
|
+
CheckCallback,
|
|
18
|
+
FilterQuery,
|
|
19
|
+
EntityName,
|
|
20
|
+
Dictionary,
|
|
21
|
+
EntityMetadata,
|
|
22
|
+
PrimaryKeyProp,
|
|
23
|
+
EntityRepositoryType,
|
|
24
|
+
Hidden,
|
|
25
|
+
Opt,
|
|
26
|
+
Primary,
|
|
27
|
+
EntityClass,
|
|
28
|
+
EntitySchemaWithMeta,
|
|
29
|
+
InferEntity,
|
|
30
|
+
MaybeReturnType,
|
|
31
|
+
Ref,
|
|
32
|
+
IndexCallback,
|
|
33
|
+
FormulaCallback,
|
|
34
|
+
EntityCtor,
|
|
35
|
+
IsNever,
|
|
36
|
+
IWrappedEntity,
|
|
37
|
+
DefineConfig,
|
|
38
|
+
Config,
|
|
39
|
+
} from '../typings.js';
|
|
4
40
|
import type { Raw } from '../utils/RawQueryFragment.js';
|
|
5
41
|
import type { ScalarReference } from './Reference.js';
|
|
6
42
|
import type { SerializeOptions } from '../serialization/EntitySerializer.js';
|
|
7
|
-
import type {
|
|
43
|
+
import type {
|
|
44
|
+
Cascade,
|
|
45
|
+
DeferMode,
|
|
46
|
+
EmbeddedPrefixMode,
|
|
47
|
+
LoadStrategy,
|
|
48
|
+
QueryOrderKeysFlat,
|
|
49
|
+
QueryOrderMap,
|
|
50
|
+
} from '../enums.js';
|
|
8
51
|
import type { EventSubscriber } from '../events/EventSubscriber.js';
|
|
9
52
|
import type { IType, Type } from '../types/Type.js';
|
|
10
53
|
import { types } from '../types/index.js';
|
|
11
54
|
import type { Collection } from './Collection.js';
|
|
12
55
|
import type { FilterOptions } from '../drivers/IDatabaseDriver.js';
|
|
13
|
-
|
|
56
|
+
/** Union of all option keys supported across all property definition types (scalar, enum, embedded, relations). */
|
|
57
|
+
export type UniversalPropertyKeys =
|
|
58
|
+
| keyof PropertyOptions<any>
|
|
59
|
+
| keyof EnumOptions<any>
|
|
60
|
+
| keyof EmbeddedOptions<any, any>
|
|
61
|
+
| keyof ReferenceOptions<any, any>
|
|
62
|
+
| keyof ManyToOneOptions<any, any>
|
|
63
|
+
| keyof OneToManyOptions<any, any>
|
|
64
|
+
| keyof OneToOneOptions<any, any>
|
|
65
|
+
| keyof ManyToManyOptions<any, any>;
|
|
14
66
|
type BuilderExtraKeys = '~options' | '~type' | '$type';
|
|
15
67
|
type ExcludeKeys = 'entity' | 'items';
|
|
16
68
|
type BuilderKeys = Exclude<UniversalPropertyKeys, ExcludeKeys> | BuilderExtraKeys;
|
|
@@ -18,679 +70,1303 @@ type IncludeKeysForProperty = Exclude<keyof PropertyOptions<any>, ExcludeKeys> |
|
|
|
18
70
|
type IncludeKeysForEnumOptions = Exclude<keyof EnumOptions<any>, ExcludeKeys> | BuilderExtraKeys;
|
|
19
71
|
type IncludeKeysForOneToManyOptions = Exclude<keyof OneToManyOptions<any, any>, ExcludeKeys> | BuilderExtraKeys;
|
|
20
72
|
type HasKind<Options, K extends string> = Options extends {
|
|
21
|
-
|
|
22
|
-
}
|
|
73
|
+
kind: infer X extends string;
|
|
74
|
+
}
|
|
75
|
+
? X extends K
|
|
76
|
+
? true
|
|
77
|
+
: false
|
|
78
|
+
: false;
|
|
23
79
|
/** Lightweight chain result type for property builders - reduces type instantiation cost by avoiding full class resolution. */
|
|
24
80
|
export interface PropertyChain<Value, Options> {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
81
|
+
'~type'?: {
|
|
82
|
+
value: Value;
|
|
83
|
+
};
|
|
84
|
+
'~options': Options;
|
|
85
|
+
$type<T>(): PropertyChain<T, Options>;
|
|
86
|
+
$type<Runtime, Raw, Serialized = Raw>(): PropertyChain<IType<Runtime, Raw, Serialized>, Options>;
|
|
87
|
+
nullable(): PropertyChain<
|
|
88
|
+
Value,
|
|
89
|
+
Omit<Options, 'nullable'> & {
|
|
90
|
+
nullable: true;
|
|
91
|
+
}
|
|
92
|
+
>;
|
|
93
|
+
ref(): PropertyChain<
|
|
94
|
+
Value,
|
|
95
|
+
Omit<Options, 'ref'> & {
|
|
96
|
+
ref: true;
|
|
97
|
+
}
|
|
98
|
+
>;
|
|
99
|
+
primary(): PropertyChain<
|
|
100
|
+
Value,
|
|
101
|
+
Omit<Options, 'primary'> & {
|
|
102
|
+
primary: true;
|
|
103
|
+
}
|
|
104
|
+
>;
|
|
105
|
+
hidden(): PropertyChain<
|
|
106
|
+
Value,
|
|
107
|
+
Omit<Options, 'hidden'> & {
|
|
108
|
+
hidden: true;
|
|
109
|
+
}
|
|
110
|
+
>;
|
|
111
|
+
autoincrement(): PropertyChain<
|
|
112
|
+
Value,
|
|
113
|
+
Omit<Options, 'autoincrement'> & {
|
|
114
|
+
autoincrement: true;
|
|
115
|
+
}
|
|
116
|
+
>;
|
|
117
|
+
autoincrement(autoincrement: false): PropertyChain<
|
|
118
|
+
Value,
|
|
119
|
+
Omit<Options, 'autoincrement'> & {
|
|
120
|
+
autoincrement: false;
|
|
121
|
+
}
|
|
122
|
+
>;
|
|
123
|
+
persist(): PropertyChain<
|
|
124
|
+
Value,
|
|
125
|
+
Omit<Options, 'persist'> & {
|
|
126
|
+
persist: true;
|
|
127
|
+
}
|
|
128
|
+
>;
|
|
129
|
+
persist(persist: false): PropertyChain<
|
|
130
|
+
Value,
|
|
131
|
+
Omit<Options, 'persist'> & {
|
|
132
|
+
persist: false;
|
|
133
|
+
}
|
|
134
|
+
>;
|
|
135
|
+
version(): PropertyChain<
|
|
136
|
+
Value,
|
|
137
|
+
Omit<Options, 'version'> & {
|
|
138
|
+
version: true;
|
|
139
|
+
}
|
|
140
|
+
>;
|
|
141
|
+
lazy(): PropertyChain<Value, Options>;
|
|
142
|
+
name<T extends string>(
|
|
143
|
+
name: T,
|
|
144
|
+
): PropertyChain<
|
|
145
|
+
Value,
|
|
146
|
+
Omit<Options, 'fieldName'> & {
|
|
147
|
+
fieldName: T;
|
|
148
|
+
}
|
|
149
|
+
>;
|
|
150
|
+
fieldName<T extends string>(
|
|
151
|
+
fieldName: T,
|
|
152
|
+
): PropertyChain<
|
|
153
|
+
Value,
|
|
154
|
+
Omit<Options, 'fieldName'> & {
|
|
155
|
+
fieldName: T;
|
|
156
|
+
}
|
|
157
|
+
>;
|
|
158
|
+
onCreate(onCreate: (entity: any, em: EntityManager) => Value): PropertyChain<
|
|
159
|
+
Value,
|
|
160
|
+
Options & {
|
|
161
|
+
onCreate: (...args: any[]) => any;
|
|
162
|
+
}
|
|
163
|
+
>;
|
|
164
|
+
default(defaultValue: string | string[] | number | number[] | boolean | null | Date | Raw): PropertyChain<
|
|
165
|
+
Value,
|
|
166
|
+
Omit<Options, 'default'> & {
|
|
167
|
+
default: any;
|
|
168
|
+
}
|
|
169
|
+
>;
|
|
170
|
+
defaultRaw(defaultRaw: string): PropertyChain<
|
|
171
|
+
Value,
|
|
172
|
+
Options & {
|
|
173
|
+
defaultRaw: string;
|
|
174
|
+
}
|
|
175
|
+
>;
|
|
176
|
+
formula(formula: string | FormulaCallback<any>): PropertyChain<
|
|
177
|
+
Value,
|
|
178
|
+
Omit<Options, 'formula'> & {
|
|
179
|
+
formula: any;
|
|
180
|
+
}
|
|
181
|
+
>;
|
|
182
|
+
onUpdate(onUpdate: (entity: any, em: EntityManager) => Value): PropertyChain<Value, Options>;
|
|
183
|
+
fieldNames(...fieldNames: string[]): PropertyChain<Value, Options>;
|
|
184
|
+
type(type: PropertyValueType): PropertyChain<Value, Options>;
|
|
185
|
+
runtimeType(runtimeType: string): PropertyChain<Value, Options>;
|
|
186
|
+
columnType(columnType: ColumnType | AnyString): PropertyChain<Value, Options>;
|
|
187
|
+
columnTypes(...columnTypes: (ColumnType | AnyString)[]): PropertyChain<Value, Options>;
|
|
188
|
+
length(length: number): PropertyChain<Value, Options>;
|
|
189
|
+
precision(precision: number): PropertyChain<Value, Options>;
|
|
190
|
+
scale(scale: number): PropertyChain<Value, Options>;
|
|
191
|
+
returning(returning?: boolean): PropertyChain<Value, Options>;
|
|
192
|
+
unsigned(unsigned?: boolean): PropertyChain<Value, Options>;
|
|
193
|
+
hydrate(hydrate?: boolean): PropertyChain<Value, Options>;
|
|
194
|
+
concurrencyCheck(concurrencyCheck?: boolean): PropertyChain<Value, Options>;
|
|
195
|
+
generated(generated: string | GeneratedColumnCallback<any>): PropertyChain<Value, Options>;
|
|
196
|
+
check(check: string | CheckCallback<any>): PropertyChain<Value, Options>;
|
|
197
|
+
setter(setter?: boolean): PropertyChain<Value, Options>;
|
|
198
|
+
getter(getter?: boolean): PropertyChain<Value, Options>;
|
|
199
|
+
getterName(getterName: string): PropertyChain<Value, Options>;
|
|
200
|
+
serializedPrimaryKey(serializedPrimaryKey?: boolean): PropertyChain<Value, Options>;
|
|
201
|
+
serializer(serializer: (value: Value, options?: SerializeOptions<any>) => any): PropertyChain<Value, Options>;
|
|
202
|
+
serializedName(serializedName: string): PropertyChain<Value, Options>;
|
|
203
|
+
groups(...groups: string[]): PropertyChain<Value, Options>;
|
|
204
|
+
customOrder(...customOrder: string[] | number[] | boolean[]): PropertyChain<Value, Options>;
|
|
205
|
+
extra(extra: string): PropertyChain<Value, Options>;
|
|
206
|
+
ignoreSchemaChanges(...ignoreSchemaChanges: ('type' | 'extra' | 'default')[]): PropertyChain<Value, Options>;
|
|
207
|
+
index(index?: boolean | string): PropertyChain<Value, Options>;
|
|
208
|
+
unique(unique?: boolean | string): PropertyChain<Value, Options>;
|
|
209
|
+
comment(comment: string): PropertyChain<Value, Options>;
|
|
210
|
+
accessor(accessor?: string | boolean): PropertyChain<Value, Options>;
|
|
211
|
+
eager(
|
|
212
|
+
eager?: boolean,
|
|
213
|
+
): HasKind<Options, 'm:1' | '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
|
|
214
|
+
cascade(
|
|
215
|
+
...cascade: Cascade[]
|
|
216
|
+
): HasKind<Options, 'm:1' | '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
|
|
217
|
+
strategy(
|
|
218
|
+
strategy: LoadStrategy | `${LoadStrategy}`,
|
|
219
|
+
): HasKind<Options, 'm:1' | '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
|
|
220
|
+
filters(
|
|
221
|
+
filters: FilterOptions,
|
|
222
|
+
): HasKind<Options, 'm:1' | '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
|
|
223
|
+
mappedBy(
|
|
224
|
+
mappedBy: (keyof Value & string) | ((e: Value) => any),
|
|
225
|
+
): HasKind<Options, '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
|
|
226
|
+
inversedBy(
|
|
227
|
+
inversedBy: (keyof Value & string) | ((e: Value) => any),
|
|
228
|
+
): HasKind<Options, 'm:1' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
|
|
229
|
+
owner(): HasKind<Options, '1:1' | 'm:n'> extends true
|
|
230
|
+
? PropertyChain<
|
|
231
|
+
Value,
|
|
232
|
+
Omit<Options, 'owner'> & {
|
|
233
|
+
owner: true;
|
|
234
|
+
}
|
|
235
|
+
>
|
|
236
|
+
: never;
|
|
237
|
+
mapToPk(): HasKind<Options, 'm:1' | '1:1'> extends true
|
|
238
|
+
? PropertyChain<
|
|
239
|
+
Value,
|
|
240
|
+
Omit<Options, 'mapToPk'> & {
|
|
241
|
+
mapToPk: true;
|
|
242
|
+
}
|
|
243
|
+
>
|
|
244
|
+
: never;
|
|
245
|
+
orphanRemoval(
|
|
246
|
+
orphanRemoval?: boolean,
|
|
247
|
+
): HasKind<Options, '1:m' | '1:1'> extends true ? PropertyChain<Value, Options> : never;
|
|
248
|
+
discriminator(
|
|
249
|
+
discriminator: string,
|
|
250
|
+
): HasKind<Options, 'm:1' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
|
|
251
|
+
discriminatorMap(
|
|
252
|
+
discriminatorMap: Dictionary<string>,
|
|
253
|
+
): HasKind<Options, 'm:1' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
|
|
254
|
+
pivotTable(pivotTable: string): HasKind<Options, 'm:n'> extends true ? PropertyChain<Value, Options> : never;
|
|
255
|
+
pivotEntity(
|
|
256
|
+
pivotEntity: () => EntityName,
|
|
257
|
+
): HasKind<Options, 'm:n'> extends true ? PropertyChain<Value, Options> : never;
|
|
258
|
+
fixedOrder(fixedOrder?: boolean): HasKind<Options, 'm:n'> extends true ? PropertyChain<Value, Options> : never;
|
|
259
|
+
fixedOrderColumn(
|
|
260
|
+
fixedOrderColumn: string,
|
|
261
|
+
): HasKind<Options, 'm:n'> extends true ? PropertyChain<Value, Options> : never;
|
|
262
|
+
array(): HasKind<Options, 'embedded' | 'enum'> extends true
|
|
263
|
+
? PropertyChain<
|
|
264
|
+
Value,
|
|
265
|
+
Omit<Options, 'array'> & {
|
|
266
|
+
array: true;
|
|
267
|
+
}
|
|
268
|
+
>
|
|
269
|
+
: never;
|
|
270
|
+
prefix(prefix: string | boolean): HasKind<Options, 'embedded'> extends true ? PropertyChain<Value, Options> : never;
|
|
271
|
+
prefixMode(
|
|
272
|
+
prefixMode: EmbeddedPrefixMode,
|
|
273
|
+
): HasKind<Options, 'embedded'> extends true ? PropertyChain<Value, Options> : never;
|
|
274
|
+
object(object?: boolean): HasKind<Options, 'embedded'> extends true ? PropertyChain<Value, Options> : never;
|
|
275
|
+
nativeEnumName(nativeEnumName: string): HasKind<Options, 'enum'> extends true ? PropertyChain<Value, Options> : never;
|
|
276
|
+
orderBy(
|
|
277
|
+
...orderBy: QueryOrderMap<object>[]
|
|
278
|
+
): HasKind<Options, 'm:1' | '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
|
|
279
|
+
where(
|
|
280
|
+
...where: FilterQuery<object>[]
|
|
281
|
+
): HasKind<Options, 'm:1' | '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
|
|
282
|
+
joinColumn(
|
|
283
|
+
joinColumn: string,
|
|
284
|
+
): HasKind<Options, 'm:1' | '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
|
|
285
|
+
joinColumns(
|
|
286
|
+
...joinColumns: string[]
|
|
287
|
+
): HasKind<Options, 'm:1' | '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
|
|
288
|
+
inverseJoinColumn(
|
|
289
|
+
inverseJoinColumn: string,
|
|
290
|
+
): HasKind<Options, 'm:1' | '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
|
|
291
|
+
inverseJoinColumns(
|
|
292
|
+
...inverseJoinColumns: string[]
|
|
293
|
+
): HasKind<Options, 'm:1' | '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
|
|
294
|
+
referenceColumnName(
|
|
295
|
+
referenceColumnName: string,
|
|
296
|
+
): HasKind<Options, 'm:1' | '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
|
|
297
|
+
referencedColumnNames(
|
|
298
|
+
...referencedColumnNames: string[]
|
|
299
|
+
): HasKind<Options, 'm:1' | '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
|
|
300
|
+
ownColumns(
|
|
301
|
+
...ownColumns: string[]
|
|
302
|
+
): HasKind<Options, 'm:1' | '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
|
|
303
|
+
targetKey(
|
|
304
|
+
targetKey: keyof Value & string,
|
|
305
|
+
): HasKind<Options, 'm:1' | '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
|
|
306
|
+
deleteRule(
|
|
307
|
+
deleteRule: 'cascade' | 'no action' | 'set null' | 'set default' | AnyString,
|
|
308
|
+
): HasKind<Options, 'm:1' | '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
|
|
309
|
+
updateRule(
|
|
310
|
+
updateRule: 'cascade' | 'no action' | 'set null' | 'set default' | AnyString,
|
|
311
|
+
): HasKind<Options, 'm:1' | '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
|
|
312
|
+
deferMode(
|
|
313
|
+
deferMode: DeferMode | `${DeferMode}`,
|
|
314
|
+
): HasKind<Options, 'm:1' | '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
|
|
315
|
+
createForeignKeyConstraint(
|
|
316
|
+
createForeignKeyConstraint?: boolean,
|
|
317
|
+
): HasKind<Options, 'm:1' | '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
|
|
318
|
+
foreignKeyName(
|
|
319
|
+
foreignKeyName: string,
|
|
320
|
+
): HasKind<Options, 'm:1' | '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
|
|
147
321
|
}
|
|
148
322
|
/** @internal */
|
|
149
|
-
export declare class UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys extends BuilderKeys> implements Record<
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
323
|
+
export declare class UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys extends BuilderKeys> implements Record<
|
|
324
|
+
Exclude<UniversalPropertyKeys, ExcludeKeys>,
|
|
325
|
+
any
|
|
326
|
+
> {
|
|
327
|
+
'~options': Options;
|
|
328
|
+
'~type'?: {
|
|
329
|
+
value: Value;
|
|
330
|
+
};
|
|
331
|
+
constructor(options: any);
|
|
332
|
+
protected assignOptions(options: EmptyOptions): any;
|
|
333
|
+
/**
|
|
334
|
+
* Set the TypeScript type of the property.
|
|
335
|
+
*/
|
|
336
|
+
$type<T>(): UniversalPropertyOptionsBuilder<T, Options, IncludeKeys>;
|
|
337
|
+
/**
|
|
338
|
+
* Set the TypeScript type for custom types that map to objects.
|
|
339
|
+
* This method provides type safety for custom types by specifying the runtime type,
|
|
340
|
+
* raw database value type, and optional serialized type.
|
|
341
|
+
*
|
|
342
|
+
* @template Runtime - The runtime type that the property will have in JavaScript
|
|
343
|
+
* @template Raw - The raw value type as stored in the database
|
|
344
|
+
* @template Serialized - The type when serialized (defaults to Raw)
|
|
345
|
+
* @returns PropertyOptionsBuilder with IType wrapper for type safety
|
|
346
|
+
*/
|
|
347
|
+
$type<Runtime, Raw, Serialized = Raw>(): UniversalPropertyOptionsBuilder<
|
|
348
|
+
IType<Runtime, Raw, Serialized>,
|
|
349
|
+
Options,
|
|
350
|
+
IncludeKeys
|
|
351
|
+
>;
|
|
352
|
+
/**
|
|
353
|
+
* Alias for `fieldName`.
|
|
354
|
+
*/
|
|
355
|
+
name<T extends string>(
|
|
356
|
+
name: T,
|
|
357
|
+
): Pick<
|
|
358
|
+
UniversalPropertyOptionsBuilder<
|
|
359
|
+
Value,
|
|
360
|
+
Omit<Options, 'fieldName'> & {
|
|
175
361
|
fieldName: T;
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
362
|
+
},
|
|
363
|
+
IncludeKeys
|
|
364
|
+
>,
|
|
365
|
+
IncludeKeys
|
|
366
|
+
>;
|
|
367
|
+
/**
|
|
368
|
+
* Specify database column name for this property.
|
|
369
|
+
*
|
|
370
|
+
* @see https://mikro-orm.io/docs/naming-strategy
|
|
371
|
+
*/
|
|
372
|
+
fieldName<T extends string>(
|
|
373
|
+
fieldName: T,
|
|
374
|
+
): Pick<
|
|
375
|
+
UniversalPropertyOptionsBuilder<
|
|
376
|
+
Value,
|
|
377
|
+
Omit<Options, 'fieldName'> & {
|
|
183
378
|
fieldName: T;
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
379
|
+
},
|
|
380
|
+
IncludeKeys
|
|
381
|
+
>,
|
|
382
|
+
IncludeKeys
|
|
383
|
+
>;
|
|
384
|
+
/**
|
|
385
|
+
* Specify database column names for this property.
|
|
386
|
+
* Same as `fieldName` but for composite FKs.
|
|
387
|
+
*
|
|
388
|
+
* @see https://mikro-orm.io/docs/naming-strategy
|
|
389
|
+
*/
|
|
390
|
+
fieldNames(...fieldNames: string[]): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
391
|
+
/**
|
|
392
|
+
* Specify an exact database column type for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}. This option is only for simple properties represented by a single column. (SQL only)
|
|
393
|
+
*/
|
|
394
|
+
columnType(
|
|
395
|
+
columnType: ColumnType | AnyString,
|
|
396
|
+
): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
397
|
+
/**
|
|
398
|
+
* Specify an exact database column type for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}. This option is suitable for composite keys, where one property is represented by multiple columns. (SQL only)
|
|
399
|
+
*/
|
|
400
|
+
columnTypes(
|
|
401
|
+
...columnTypes: (ColumnType | AnyString)[]
|
|
402
|
+
): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
403
|
+
/**
|
|
404
|
+
* Explicitly specify the runtime type.
|
|
405
|
+
*
|
|
406
|
+
* @see https://mikro-orm.io/docs/metadata-providers
|
|
407
|
+
* @see https://mikro-orm.io/docs/custom-types
|
|
408
|
+
*/
|
|
409
|
+
type<TType extends PropertyValueType>(
|
|
410
|
+
type: TType,
|
|
411
|
+
): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
412
|
+
/**
|
|
413
|
+
* Runtime type of the property. This is the JS type that your property is mapped to, e.g. `string` or `number`, and is normally inferred automatically via `reflect-metadata`.
|
|
414
|
+
* In some cases, the inference won't work, and you might need to specify the `runtimeType` explicitly - the most common one is when you use a union type with null like `foo: number | null`.
|
|
415
|
+
*/
|
|
416
|
+
runtimeType(runtimeType: string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
417
|
+
/**
|
|
418
|
+
* Set length of database column, used for datetime/timestamp/varchar column types for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}. (SQL only)
|
|
419
|
+
*/
|
|
420
|
+
length(length: number): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
421
|
+
/**
|
|
422
|
+
* Set precision of database column to represent the number of significant digits. (SQL only)
|
|
423
|
+
*/
|
|
424
|
+
precision(precision: number): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
425
|
+
/**
|
|
426
|
+
* Set scale of database column to represents the number of digits after the decimal point. (SQL only)
|
|
427
|
+
*/
|
|
428
|
+
scale(scale: number): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
429
|
+
/**
|
|
430
|
+
* Explicitly specify the auto increment of the primary key.
|
|
431
|
+
*/
|
|
432
|
+
autoincrement(): Pick<
|
|
433
|
+
UniversalPropertyOptionsBuilder<
|
|
434
|
+
Value,
|
|
435
|
+
Omit<Options, 'autoincrement'> & {
|
|
228
436
|
autoincrement: true;
|
|
229
|
-
|
|
230
|
-
|
|
437
|
+
},
|
|
438
|
+
IncludeKeys
|
|
439
|
+
>,
|
|
440
|
+
IncludeKeys
|
|
441
|
+
>;
|
|
442
|
+
autoincrement(autoincrement: false): Pick<
|
|
443
|
+
UniversalPropertyOptionsBuilder<
|
|
444
|
+
Value,
|
|
445
|
+
Omit<Options, 'autoincrement'> & {
|
|
231
446
|
autoincrement: false;
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
447
|
+
},
|
|
448
|
+
IncludeKeys
|
|
449
|
+
>,
|
|
450
|
+
IncludeKeys
|
|
451
|
+
>;
|
|
452
|
+
/**
|
|
453
|
+
* Add the property to the `returning` statement.
|
|
454
|
+
*/
|
|
455
|
+
returning(returning?: boolean): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
456
|
+
/**
|
|
457
|
+
* Automatically set the property value when entity gets created, executed during flush operation.
|
|
458
|
+
*/
|
|
459
|
+
onCreate(onCreate: (entity: any, em: EntityManager) => Value): Pick<
|
|
460
|
+
UniversalPropertyOptionsBuilder<
|
|
461
|
+
Value,
|
|
462
|
+
Options & {
|
|
241
463
|
onCreate: (...args: any[]) => any;
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
464
|
+
},
|
|
465
|
+
IncludeKeys
|
|
466
|
+
>,
|
|
467
|
+
IncludeKeys
|
|
468
|
+
>;
|
|
469
|
+
/**
|
|
470
|
+
* Automatically update the property value every time entity gets updated, executed during flush operation.
|
|
471
|
+
*/
|
|
472
|
+
onUpdate(
|
|
473
|
+
onUpdate: (entity: any, em: EntityManager) => Value,
|
|
474
|
+
): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
475
|
+
/**
|
|
476
|
+
* Specify default column value for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}.
|
|
477
|
+
* This is a runtime value, assignable to the entity property. (SQL only)
|
|
478
|
+
*/
|
|
479
|
+
default<T extends string | string[] | number | number[] | boolean | null | Date | Raw>(
|
|
480
|
+
defaultValue: T,
|
|
481
|
+
): Pick<
|
|
482
|
+
UniversalPropertyOptionsBuilder<
|
|
483
|
+
Value,
|
|
484
|
+
Omit<Options, 'default'> & {
|
|
252
485
|
default: T;
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
486
|
+
},
|
|
487
|
+
IncludeKeys
|
|
488
|
+
>,
|
|
489
|
+
IncludeKeys
|
|
490
|
+
>;
|
|
491
|
+
/**
|
|
492
|
+
* Specify SQL functions for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}. (SQL only)
|
|
493
|
+
* Since v4 you should use defaultRaw for SQL functions. e.g. now()
|
|
494
|
+
*/
|
|
495
|
+
defaultRaw(defaultRaw: string): Pick<
|
|
496
|
+
UniversalPropertyOptionsBuilder<
|
|
497
|
+
Value,
|
|
498
|
+
Options & {
|
|
259
499
|
defaultRaw: string;
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
500
|
+
},
|
|
501
|
+
IncludeKeys
|
|
502
|
+
>,
|
|
503
|
+
IncludeKeys
|
|
504
|
+
>;
|
|
505
|
+
/**
|
|
506
|
+
* Allow controlling `filters` option. This will be overridden with `em.fork` or `FindOptions` if provided.
|
|
507
|
+
*/
|
|
508
|
+
filters(filters: FilterOptions): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
509
|
+
/**
|
|
510
|
+
* Set to map some SQL snippet for the entity.
|
|
511
|
+
*
|
|
512
|
+
* @see https://mikro-orm.io/docs/defining-entities#formulas Formulas
|
|
513
|
+
*/
|
|
514
|
+
formula<T extends string | FormulaCallback<any>>(
|
|
515
|
+
formula: T,
|
|
516
|
+
): Pick<
|
|
517
|
+
UniversalPropertyOptionsBuilder<
|
|
518
|
+
Value,
|
|
519
|
+
Omit<Options, 'formula'> & {
|
|
271
520
|
formula: T;
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
521
|
+
},
|
|
522
|
+
IncludeKeys
|
|
523
|
+
>,
|
|
524
|
+
IncludeKeys
|
|
525
|
+
>;
|
|
526
|
+
/**
|
|
527
|
+
* For generated columns. This will be appended to the column type after the `generated always` clause.
|
|
528
|
+
*/
|
|
529
|
+
generated(
|
|
530
|
+
generated: string | GeneratedColumnCallback<any>,
|
|
531
|
+
): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
532
|
+
/**
|
|
533
|
+
* Set column as nullable for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}.
|
|
534
|
+
*/
|
|
535
|
+
nullable(): Pick<
|
|
536
|
+
UniversalPropertyOptionsBuilder<
|
|
537
|
+
Value,
|
|
538
|
+
Omit<Options, 'nullable'> & {
|
|
281
539
|
nullable: true;
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
540
|
+
},
|
|
541
|
+
IncludeKeys
|
|
542
|
+
>,
|
|
543
|
+
IncludeKeys
|
|
544
|
+
>;
|
|
545
|
+
/**
|
|
546
|
+
* Set column as unsigned for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}. (SQL only)
|
|
547
|
+
*/
|
|
548
|
+
unsigned(unsigned?: boolean): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
549
|
+
/**
|
|
550
|
+
* Set false to define {@link https://mikro-orm.io/docs/serializing#shadow-properties Shadow Property}.
|
|
551
|
+
*/
|
|
552
|
+
persist(): Pick<
|
|
553
|
+
UniversalPropertyOptionsBuilder<
|
|
554
|
+
Value,
|
|
555
|
+
Omit<Options, 'persist'> & {
|
|
291
556
|
persist: true;
|
|
292
|
-
|
|
293
|
-
|
|
557
|
+
},
|
|
558
|
+
IncludeKeys
|
|
559
|
+
>,
|
|
560
|
+
IncludeKeys
|
|
561
|
+
>;
|
|
562
|
+
persist(persist: false): Pick<
|
|
563
|
+
UniversalPropertyOptionsBuilder<
|
|
564
|
+
Value,
|
|
565
|
+
Omit<Options, 'persist'> & {
|
|
294
566
|
persist: false;
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
567
|
+
},
|
|
568
|
+
IncludeKeys
|
|
569
|
+
>,
|
|
570
|
+
IncludeKeys
|
|
571
|
+
>;
|
|
572
|
+
/**
|
|
573
|
+
* Set false to disable hydration of this property. Useful for persisted getters.
|
|
574
|
+
*/
|
|
575
|
+
hydrate(hydrate?: boolean): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
576
|
+
/**
|
|
577
|
+
* Enable `ScalarReference` wrapper for lazy values. Use this in combination with `lazy: true` to have a type-safe accessor object in place of the value.
|
|
578
|
+
*/
|
|
579
|
+
ref(): UniversalPropertyOptionsBuilder<
|
|
580
|
+
Value,
|
|
581
|
+
Omit<Options, 'ref'> & {
|
|
582
|
+
ref: true;
|
|
583
|
+
},
|
|
584
|
+
IncludeKeys
|
|
585
|
+
>;
|
|
586
|
+
/**
|
|
587
|
+
* Set to true to omit the property when {@link https://mikro-orm.io/docs/serializing Serializing}.
|
|
588
|
+
*/
|
|
589
|
+
hidden(): Pick<
|
|
590
|
+
UniversalPropertyOptionsBuilder<
|
|
591
|
+
Value,
|
|
592
|
+
Omit<Options, 'hidden'> & {
|
|
310
593
|
hidden: true;
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
594
|
+
},
|
|
595
|
+
IncludeKeys
|
|
596
|
+
>,
|
|
597
|
+
IncludeKeys
|
|
598
|
+
>;
|
|
599
|
+
/**
|
|
600
|
+
* Set to true to enable {@link https://mikro-orm.io/docs/transactions#optimistic-locking Optimistic Locking} via version field. (SQL only)
|
|
601
|
+
*/
|
|
602
|
+
version(): Pick<
|
|
603
|
+
UniversalPropertyOptionsBuilder<
|
|
604
|
+
Value,
|
|
605
|
+
Omit<Options, 'version'> & {
|
|
316
606
|
version: true;
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
607
|
+
},
|
|
608
|
+
IncludeKeys
|
|
609
|
+
>,
|
|
610
|
+
IncludeKeys
|
|
611
|
+
>;
|
|
612
|
+
/**
|
|
613
|
+
* Set to true to enable {@link https://mikro-orm.io/docs/transactions#optimistic-locking Optimistic Locking} via concurrency fields.
|
|
614
|
+
*/
|
|
615
|
+
concurrencyCheck(
|
|
616
|
+
concurrencyCheck?: boolean,
|
|
617
|
+
): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
618
|
+
/**
|
|
619
|
+
* Explicitly specify index on a property.
|
|
620
|
+
*/
|
|
621
|
+
index(index?: boolean | string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
622
|
+
/**
|
|
623
|
+
* Set column as unique for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}. (SQL only)
|
|
624
|
+
*/
|
|
625
|
+
unique(unique?: boolean | string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
626
|
+
/**
|
|
627
|
+
* Specify column with check constraints. (Postgres driver only)
|
|
628
|
+
*
|
|
629
|
+
* @see https://mikro-orm.io/docs/defining-entities#check-constraints
|
|
630
|
+
*/
|
|
631
|
+
check(
|
|
632
|
+
check: string | CheckCallback<any>,
|
|
633
|
+
): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
634
|
+
/**
|
|
635
|
+
* Set to omit the property from the select clause for lazy loading.
|
|
636
|
+
*
|
|
637
|
+
* @see https://mikro-orm.io/docs/defining-entities#lazy-scalar-properties
|
|
638
|
+
*/
|
|
639
|
+
lazy(): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
640
|
+
/**
|
|
641
|
+
* Set true to define entity's unique primary key identifier.
|
|
642
|
+
*
|
|
643
|
+
* @see https://mikro-orm.io/docs/decorators#primarykey
|
|
644
|
+
*/
|
|
645
|
+
primary(): Pick<
|
|
646
|
+
UniversalPropertyOptionsBuilder<
|
|
647
|
+
Value,
|
|
648
|
+
Omit<Options, 'primary'> & {
|
|
348
649
|
primary: true;
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
650
|
+
},
|
|
651
|
+
IncludeKeys
|
|
652
|
+
>,
|
|
653
|
+
IncludeKeys
|
|
654
|
+
>;
|
|
655
|
+
/**
|
|
656
|
+
* Set true to define the properties as setter. (virtual)
|
|
657
|
+
*
|
|
658
|
+
* @example
|
|
659
|
+
* ```
|
|
660
|
+
* @Property({ setter: true })
|
|
661
|
+
* set address(value: string) {
|
|
662
|
+
* this._address = value.toLocaleLowerCase();
|
|
663
|
+
* }
|
|
664
|
+
* ```
|
|
665
|
+
*/
|
|
666
|
+
setter(setter?: boolean): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
667
|
+
/**
|
|
668
|
+
* Set true to define the properties as getter. (virtual)
|
|
669
|
+
*
|
|
670
|
+
* @example
|
|
671
|
+
* ```
|
|
672
|
+
* @Property({ getter: true })
|
|
673
|
+
* get fullName() {
|
|
674
|
+
* return this.firstName + this.lastName;
|
|
675
|
+
* }
|
|
676
|
+
* ```
|
|
677
|
+
*/
|
|
678
|
+
getter(getter?: boolean): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
679
|
+
/**
|
|
680
|
+
* When defining a property over a method (not a getter, a regular function), you can use this option to point
|
|
681
|
+
* to the method name.
|
|
682
|
+
*
|
|
683
|
+
* @example
|
|
684
|
+
* ```
|
|
685
|
+
* @Property({ getter: true })
|
|
686
|
+
* getFullName() {
|
|
687
|
+
* return this.firstName + this.lastName;
|
|
688
|
+
* }
|
|
689
|
+
* ```
|
|
690
|
+
*/
|
|
691
|
+
getterName(getterName: string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
692
|
+
/**
|
|
693
|
+
* Set to define serialized primary key for MongoDB. (virtual)
|
|
694
|
+
* Alias for `@SerializedPrimaryKey()` decorator.
|
|
695
|
+
*
|
|
696
|
+
* @see https://mikro-orm.io/docs/decorators#serializedprimarykey
|
|
697
|
+
*/
|
|
698
|
+
serializedPrimaryKey(
|
|
699
|
+
serializedPrimaryKey?: boolean,
|
|
700
|
+
): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
701
|
+
/**
|
|
702
|
+
* Set to use serialize property. Allow to specify a callback that will be used when serializing a property.
|
|
703
|
+
*
|
|
704
|
+
* @see https://mikro-orm.io/docs/serializing#property-serializers
|
|
705
|
+
*/
|
|
706
|
+
serializer(
|
|
707
|
+
serializer: (value: Value, options?: SerializeOptions<any>) => any,
|
|
708
|
+
): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
709
|
+
/**
|
|
710
|
+
* Specify name of key for the serialized value.
|
|
711
|
+
*/
|
|
712
|
+
serializedName(
|
|
713
|
+
serializedName: string,
|
|
714
|
+
): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
715
|
+
/**
|
|
716
|
+
* Specify serialization groups for `serialize()` calls. If a property does not specify any group, it will be included,
|
|
717
|
+
* otherwise only properties with a matching group are included.
|
|
718
|
+
*/
|
|
719
|
+
groups(...groups: string[]): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
720
|
+
/**
|
|
721
|
+
* Specify a custom order based on the values. (SQL only)
|
|
722
|
+
*/
|
|
723
|
+
customOrder(
|
|
724
|
+
...customOrder: string[] | number[] | boolean[]
|
|
725
|
+
): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
726
|
+
/**
|
|
727
|
+
* Specify comment of column for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}. (SQL only)
|
|
728
|
+
*/
|
|
729
|
+
comment(comment: string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
730
|
+
/** mysql only */
|
|
731
|
+
extra(extra: string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
732
|
+
/**
|
|
733
|
+
* Set to avoid a perpetual diff from the {@link https://mikro-orm.io/docs/schema-generator Schema Generator} when columns are generated.
|
|
734
|
+
*
|
|
735
|
+
* @see https://mikro-orm.io/docs/defining-entities#sql-generated-columns
|
|
736
|
+
*/
|
|
737
|
+
ignoreSchemaChanges(
|
|
738
|
+
...ignoreSchemaChanges: ('type' | 'extra' | 'default')[]
|
|
739
|
+
): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
740
|
+
array(): Pick<
|
|
741
|
+
UniversalPropertyOptionsBuilder<
|
|
742
|
+
Value,
|
|
743
|
+
Omit<Options, 'array'> & {
|
|
426
744
|
array: true;
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
745
|
+
},
|
|
746
|
+
IncludeKeys
|
|
747
|
+
>,
|
|
748
|
+
IncludeKeys
|
|
749
|
+
>;
|
|
750
|
+
/** for postgres, by default it uses text column with check constraint */
|
|
751
|
+
nativeEnumName(
|
|
752
|
+
nativeEnumName: string,
|
|
753
|
+
): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
754
|
+
prefix(prefix: string | boolean): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
755
|
+
prefixMode(
|
|
756
|
+
prefixMode: EmbeddedPrefixMode,
|
|
757
|
+
): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
758
|
+
object(object?: boolean): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
759
|
+
/** Set what actions on owning entity should be cascaded to the relationship. Defaults to [Cascade.PERSIST, Cascade.MERGE] (see {@doclink cascading}). */
|
|
760
|
+
cascade(...cascade: Cascade[]): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
761
|
+
/** Always load the relationship. Discouraged for use with to-many relations for performance reasons. */
|
|
762
|
+
eager(eager?: boolean): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
763
|
+
/** Override the default loading strategy for this property. This option has precedence over the global `loadStrategy`, but can be overridden by `FindOptions.strategy`. */
|
|
764
|
+
strategy(
|
|
765
|
+
strategy: LoadStrategy | `${LoadStrategy}`,
|
|
766
|
+
): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
767
|
+
/** Set this side as owning. Owning side is where the foreign key is defined. This option is not required if you use `inversedBy` or `mappedBy` to distinguish owning and inverse side. */
|
|
768
|
+
owner(): Pick<
|
|
769
|
+
UniversalPropertyOptionsBuilder<
|
|
770
|
+
Value,
|
|
771
|
+
Omit<Options, 'owner'> & {
|
|
441
772
|
owner: true;
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
773
|
+
},
|
|
774
|
+
IncludeKeys
|
|
775
|
+
>,
|
|
776
|
+
IncludeKeys
|
|
777
|
+
>;
|
|
778
|
+
/** For polymorphic relations. Specifies the property name that stores the entity type discriminator. Defaults to the property name. */
|
|
779
|
+
discriminator(discriminator: string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
780
|
+
/** For polymorphic relations. Custom mapping of discriminator values to entity class names. */
|
|
781
|
+
discriminatorMap(
|
|
782
|
+
discriminatorMap: Dictionary<string>,
|
|
783
|
+
): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
784
|
+
/** Point to the inverse side property name. */
|
|
785
|
+
inversedBy(
|
|
786
|
+
inversedBy: keyof Value | ((e: Value) => any),
|
|
787
|
+
): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
788
|
+
/** Point to the owning side property name. */
|
|
789
|
+
mappedBy(
|
|
790
|
+
mappedBy: keyof Value | ((e: Value) => any),
|
|
791
|
+
): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
792
|
+
/** Condition for {@doclink collections#declarative-partial-loading | Declarative partial loading}. */
|
|
793
|
+
where(
|
|
794
|
+
...where: FilterQuery<object>[]
|
|
795
|
+
): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
796
|
+
/** Set default ordering. */
|
|
797
|
+
orderBy(
|
|
798
|
+
...orderBy: QueryOrderMap<object>[]
|
|
799
|
+
): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
800
|
+
/** Force stable insertion order of items in the collection (see {@doclink collections | Collections}). */
|
|
801
|
+
fixedOrder(fixedOrder?: boolean): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
802
|
+
/** Override default order column name (`id`) for fixed ordering. */
|
|
803
|
+
fixedOrderColumn(
|
|
804
|
+
fixedOrderColumn: string,
|
|
805
|
+
): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
806
|
+
/** Override default name for pivot table (see {@doclink naming-strategy | Naming Strategy}). */
|
|
807
|
+
pivotTable(pivotTable: string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
808
|
+
/** Set pivot entity for this relation (see {@doclink collections#custom-pivot-table-entity | Custom pivot table entity}). */
|
|
809
|
+
pivotEntity(
|
|
810
|
+
pivotEntity: () => EntityName,
|
|
811
|
+
): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
812
|
+
/** Override the default database column name on the owning side (see {@doclink naming-strategy | Naming Strategy}). This option is only for simple properties represented by a single column. */
|
|
813
|
+
joinColumn(joinColumn: string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
814
|
+
/** Override the default database column name on the owning side (see {@doclink naming-strategy | Naming Strategy}). This option is suitable for composite keys, where one property is represented by multiple columns. */
|
|
815
|
+
joinColumns(
|
|
816
|
+
...joinColumns: string[]
|
|
817
|
+
): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
818
|
+
/** Override the default database column name on the inverse side (see {@doclink naming-strategy | Naming Strategy}). This option is only for simple properties represented by a single column. */
|
|
819
|
+
inverseJoinColumn(
|
|
820
|
+
inverseJoinColumn: string,
|
|
821
|
+
): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
822
|
+
/** Override the default database column name on the inverse side (see {@doclink naming-strategy | Naming Strategy}). This option is suitable for composite keys, where one property is represented by multiple columns. */
|
|
823
|
+
inverseJoinColumns(
|
|
824
|
+
...inverseJoinColumns: string[]
|
|
825
|
+
): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
826
|
+
/** Override the default database column name on the target entity (see {@doclink naming-strategy | Naming Strategy}). This option is only for simple properties represented by a single column. */
|
|
827
|
+
referenceColumnName(
|
|
828
|
+
referenceColumnName: string,
|
|
829
|
+
): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
830
|
+
/** Override the default database column name on the target entity (see {@doclink naming-strategy | Naming Strategy}). This option is suitable for composite keys, where one property is represented by multiple columns. */
|
|
831
|
+
referencedColumnNames(
|
|
832
|
+
...referencedColumnNames: string[]
|
|
833
|
+
): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
834
|
+
/** Specify the property name on the target entity that this FK references instead of the primary key. */
|
|
835
|
+
targetKey(targetKey: keyof Value): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
836
|
+
/** What to do when the target entity gets deleted. */
|
|
837
|
+
deleteRule(
|
|
838
|
+
deleteRule: 'cascade' | 'no action' | 'set null' | 'set default' | AnyString,
|
|
839
|
+
): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
840
|
+
/** What to do when the reference to the target entity gets updated. */
|
|
841
|
+
updateRule(
|
|
842
|
+
updateRule: 'cascade' | 'no action' | 'set null' | 'set default' | AnyString,
|
|
843
|
+
): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
844
|
+
/** Map this relation to the primary key value instead of an entity. */
|
|
845
|
+
mapToPk(): Pick<
|
|
846
|
+
UniversalPropertyOptionsBuilder<
|
|
847
|
+
Value,
|
|
848
|
+
Omit<Options, 'mapToPk'> & {
|
|
483
849
|
mapToPk: true;
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
850
|
+
},
|
|
851
|
+
IncludeKeys
|
|
852
|
+
>,
|
|
853
|
+
IncludeKeys
|
|
854
|
+
>;
|
|
855
|
+
/** Set the constraint type. Immediate constraints are checked for each statement, while deferred ones are only checked at the end of the transaction. Only for postgres unique constraints. */
|
|
856
|
+
deferMode(
|
|
857
|
+
deferMode: DeferMode | `${DeferMode}`,
|
|
858
|
+
): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
859
|
+
/** When a part of a composite column is shared in other properties, use this option to specify what columns are considered as owned by this property. This is useful when your composite property is nullable, but parts of it are not. */
|
|
860
|
+
ownColumns(...ownColumns: string[]): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
861
|
+
/** Enable/disable foreign key constraint creation on this relation */
|
|
862
|
+
createForeignKeyConstraint(
|
|
863
|
+
createForeignKeyConstraint?: boolean,
|
|
864
|
+
): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
865
|
+
/** Set a custom foreign key constraint name, overriding NamingStrategy.indexName(). */
|
|
866
|
+
foreignKeyName(
|
|
867
|
+
foreignKeyName: string,
|
|
868
|
+
): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
869
|
+
/** Remove the entity when it gets disconnected from the relationship (see {@doclink cascading | Cascading}). */
|
|
870
|
+
orphanRemoval(
|
|
871
|
+
orphanRemoval?: boolean,
|
|
872
|
+
): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
873
|
+
accessor(
|
|
874
|
+
accessor?: string | boolean,
|
|
875
|
+
): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
498
876
|
}
|
|
877
|
+
/** Empty options object used as the initial state for property builders. */
|
|
878
|
+
export interface EmptyOptions extends Partial<Record<UniversalPropertyKeys, unknown>> {}
|
|
499
879
|
/** @internal */
|
|
500
|
-
export declare class OneToManyOptionsBuilderOnlyMappedBy<Value extends object> extends UniversalPropertyOptionsBuilder<
|
|
880
|
+
export declare class OneToManyOptionsBuilderOnlyMappedBy<Value extends object> extends UniversalPropertyOptionsBuilder<
|
|
881
|
+
Value,
|
|
882
|
+
EmptyOptions & {
|
|
501
883
|
kind: '1:m';
|
|
502
|
-
},
|
|
503
|
-
|
|
504
|
-
|
|
884
|
+
},
|
|
885
|
+
IncludeKeysForOneToManyOptions
|
|
886
|
+
> {
|
|
887
|
+
/** Point to the owning side property name. */
|
|
888
|
+
mappedBy(mappedBy: keyof Value | ((e: Value) => any)): Pick<
|
|
889
|
+
UniversalPropertyOptionsBuilder<
|
|
890
|
+
Value,
|
|
891
|
+
EmptyOptions & {
|
|
505
892
|
kind: '1:m';
|
|
506
|
-
|
|
893
|
+
},
|
|
894
|
+
IncludeKeysForOneToManyOptions
|
|
895
|
+
>,
|
|
896
|
+
IncludeKeysForOneToManyOptions
|
|
897
|
+
>;
|
|
507
898
|
}
|
|
508
|
-
type EntityTarget =
|
|
509
|
-
|
|
510
|
-
|
|
899
|
+
type EntityTarget =
|
|
900
|
+
| {
|
|
901
|
+
'~entity': any;
|
|
902
|
+
}
|
|
903
|
+
| EntityClass;
|
|
511
904
|
declare const propertyBuilders: PropertyBuilders;
|
|
512
905
|
type PropertyBuildersOverrideKeys = 'bigint' | 'array' | 'decimal' | 'json' | 'datetime' | 'time' | 'enum';
|
|
906
|
+
/** Map of factory functions for creating type-safe property builders (scalars, enums, embeddables, and relations). */
|
|
513
907
|
export type PropertyBuilders = {
|
|
514
|
-
|
|
908
|
+
[K in Exclude<keyof typeof types, PropertyBuildersOverrideKeys>]: () => UniversalPropertyOptionsBuilder<
|
|
909
|
+
InferPropertyValueType<(typeof types)[K]>,
|
|
910
|
+
EmptyOptions,
|
|
911
|
+
IncludeKeysForProperty
|
|
912
|
+
>;
|
|
515
913
|
} & {
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
914
|
+
bigint: <Mode extends 'bigint' | 'number' | 'string' = 'bigint'>(
|
|
915
|
+
mode?: Mode,
|
|
916
|
+
) => UniversalPropertyOptionsBuilder<
|
|
917
|
+
InferPropertyValueType<typeof types.bigint<Mode>>,
|
|
918
|
+
EmptyOptions,
|
|
919
|
+
IncludeKeysForProperty
|
|
920
|
+
>;
|
|
921
|
+
array: <T = string>(
|
|
922
|
+
toJsValue?: (i: string) => T,
|
|
923
|
+
toDbValue?: (i: T) => string,
|
|
924
|
+
) => UniversalPropertyOptionsBuilder<
|
|
925
|
+
InferPropertyValueType<typeof types.array<T>>,
|
|
926
|
+
EmptyOptions,
|
|
927
|
+
IncludeKeysForProperty
|
|
928
|
+
>;
|
|
929
|
+
decimal: <Mode extends 'number' | 'string' = 'string'>(
|
|
930
|
+
mode?: Mode,
|
|
931
|
+
) => UniversalPropertyOptionsBuilder<
|
|
932
|
+
InferPropertyValueType<typeof types.decimal<Mode>>,
|
|
933
|
+
EmptyOptions,
|
|
934
|
+
IncludeKeysForProperty
|
|
935
|
+
>;
|
|
936
|
+
json: <T>() => UniversalPropertyOptionsBuilder<T, EmptyOptions, IncludeKeysForProperty>;
|
|
937
|
+
formula: <T>(
|
|
938
|
+
formula: string | FormulaCallback<any>,
|
|
939
|
+
) => UniversalPropertyOptionsBuilder<T, EmptyOptions, IncludeKeysForProperty>;
|
|
940
|
+
datetime: (
|
|
941
|
+
length?: number,
|
|
942
|
+
) => UniversalPropertyOptionsBuilder<
|
|
943
|
+
InferPropertyValueType<typeof types.datetime>,
|
|
944
|
+
EmptyOptions,
|
|
945
|
+
IncludeKeysForProperty
|
|
946
|
+
>;
|
|
947
|
+
time: (
|
|
948
|
+
length?: number,
|
|
949
|
+
) => UniversalPropertyOptionsBuilder<InferPropertyValueType<typeof types.time>, EmptyOptions, IncludeKeysForProperty>;
|
|
950
|
+
type: <T extends PropertyValueType>(
|
|
951
|
+
type: T,
|
|
952
|
+
) => UniversalPropertyOptionsBuilder<InferPropertyValueType<T>, EmptyOptions, IncludeKeysForProperty>;
|
|
953
|
+
enum: <const T extends (number | string)[] | (() => Dictionary)>(
|
|
954
|
+
items?: T,
|
|
955
|
+
) => UniversalPropertyOptionsBuilder<
|
|
956
|
+
T extends () => Dictionary ? ValueOf<ReturnType<T>> : T extends (infer Value)[] ? Value : T,
|
|
957
|
+
EmptyOptions,
|
|
958
|
+
IncludeKeysForEnumOptions
|
|
959
|
+
>;
|
|
960
|
+
embedded: <Target extends EntityTarget | EntityTarget[]>(
|
|
961
|
+
target: Target,
|
|
962
|
+
) => PropertyChain<
|
|
963
|
+
InferEntity<Target extends (infer T)[] ? T : Target>,
|
|
964
|
+
EmptyOptions & {
|
|
965
|
+
kind: 'embedded';
|
|
966
|
+
}
|
|
967
|
+
>;
|
|
968
|
+
manyToMany: <Target extends EntityTarget>(
|
|
969
|
+
target: Target,
|
|
970
|
+
) => PropertyChain<
|
|
971
|
+
InferEntity<Target>,
|
|
972
|
+
EmptyOptions & {
|
|
973
|
+
kind: 'm:n';
|
|
974
|
+
}
|
|
975
|
+
>;
|
|
976
|
+
manyToOne: <Target extends EntityTarget | EntityTarget[]>(
|
|
977
|
+
target: Target,
|
|
978
|
+
) => PropertyChain<
|
|
979
|
+
InferEntity<Target extends (infer T)[] ? T : Target>,
|
|
980
|
+
EmptyOptions & {
|
|
981
|
+
kind: 'm:1';
|
|
982
|
+
}
|
|
983
|
+
>;
|
|
984
|
+
oneToMany: <Target extends EntityTarget>(
|
|
985
|
+
target: Target,
|
|
986
|
+
) => PropertyChain<
|
|
987
|
+
InferEntity<Target>,
|
|
988
|
+
EmptyOptions & {
|
|
989
|
+
kind: '1:m';
|
|
990
|
+
}
|
|
991
|
+
>;
|
|
992
|
+
oneToOne: <Target extends EntityTarget | EntityTarget[]>(
|
|
993
|
+
target: Target,
|
|
994
|
+
) => PropertyChain<
|
|
995
|
+
InferEntity<Target extends (infer T)[] ? T : Target>,
|
|
996
|
+
EmptyOptions & {
|
|
997
|
+
kind: '1:1';
|
|
998
|
+
}
|
|
999
|
+
>;
|
|
540
1000
|
};
|
|
541
1001
|
/** Own keys + base entity keys (when TBase is not `never`). Guards against `keyof never = string | number | symbol`. */
|
|
542
1002
|
type AllKeys<TProperties, TBase> = keyof TProperties | (IsNever<TBase> extends true ? never : keyof TBase);
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
1003
|
+
/** Metadata descriptor for `defineEntity()`, combining entity options with property definitions. */
|
|
1004
|
+
export interface EntityMetadataWithProperties<
|
|
1005
|
+
TName extends string,
|
|
1006
|
+
TTableName extends string,
|
|
1007
|
+
TProperties extends Record<string, any>,
|
|
1008
|
+
TPK extends (keyof TProperties)[] | undefined = undefined,
|
|
1009
|
+
TBase = never,
|
|
1010
|
+
TRepository = never,
|
|
1011
|
+
TForceObject extends boolean = false,
|
|
1012
|
+
> extends Omit<
|
|
1013
|
+
Partial<EntityMetadata<InferEntityFromProperties<TProperties, TPK, TBase, TRepository>>>,
|
|
1014
|
+
| 'properties'
|
|
1015
|
+
| 'extends'
|
|
1016
|
+
| 'primaryKeys'
|
|
1017
|
+
| 'hooks'
|
|
1018
|
+
| 'discriminatorColumn'
|
|
1019
|
+
| 'versionProperty'
|
|
1020
|
+
| 'concurrencyCheckKeys'
|
|
1021
|
+
| 'serializedPrimaryKey'
|
|
1022
|
+
| 'indexes'
|
|
1023
|
+
| 'uniques'
|
|
1024
|
+
| 'repository'
|
|
1025
|
+
| 'orderBy'
|
|
1026
|
+
> {
|
|
1027
|
+
name: TName;
|
|
1028
|
+
tableName?: TTableName;
|
|
1029
|
+
extends?:
|
|
1030
|
+
| {
|
|
547
1031
|
'~entity': TBase;
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
1032
|
+
}
|
|
1033
|
+
| EntityCtor<TBase>;
|
|
1034
|
+
properties: TProperties | ((properties: PropertyBuilders) => TProperties);
|
|
1035
|
+
primaryKeys?: TPK & InferPrimaryKey<TProperties>[];
|
|
1036
|
+
hooks?: DefineEntityHooks;
|
|
1037
|
+
repository?: () => TRepository;
|
|
1038
|
+
forceObject?: TForceObject;
|
|
1039
|
+
inheritance?: 'tpt';
|
|
1040
|
+
orderBy?:
|
|
1041
|
+
| {
|
|
556
1042
|
[K in Extract<AllKeys<TProperties, TBase>, string>]?: QueryOrderKeysFlat;
|
|
557
|
-
|
|
1043
|
+
}
|
|
1044
|
+
| {
|
|
558
1045
|
[K in Extract<AllKeys<TProperties, TBase>, string>]?: QueryOrderKeysFlat;
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
1046
|
+
}[];
|
|
1047
|
+
discriminatorColumn?: string;
|
|
1048
|
+
versionProperty?: AllKeys<TProperties, TBase>;
|
|
1049
|
+
concurrencyCheckKeys?: Set<AllKeys<TProperties, TBase>>;
|
|
1050
|
+
serializedPrimaryKey?: AllKeys<TProperties, TBase>;
|
|
1051
|
+
indexes?: {
|
|
1052
|
+
properties?: keyof TProperties | (keyof TProperties)[];
|
|
1053
|
+
name?: string;
|
|
1054
|
+
type?: string;
|
|
1055
|
+
options?: Dictionary;
|
|
1056
|
+
expression?: string | IndexCallback<InferEntityFromProperties<TProperties, TPK, TBase>>;
|
|
1057
|
+
}[];
|
|
1058
|
+
uniques?: {
|
|
1059
|
+
properties?: keyof TProperties | (keyof TProperties)[];
|
|
1060
|
+
name?: string;
|
|
1061
|
+
options?: Dictionary;
|
|
1062
|
+
expression?: string | IndexCallback<InferEntityFromProperties<TProperties, TPK, TBase>>;
|
|
1063
|
+
deferMode?: DeferMode | `${DeferMode}`;
|
|
1064
|
+
}[];
|
|
578
1065
|
}
|
|
579
|
-
|
|
580
|
-
export declare function defineEntity<
|
|
1066
|
+
/** Defines an entity schema using property builders, with full type inference from the property definitions. */
|
|
1067
|
+
export declare function defineEntity<
|
|
1068
|
+
const TName extends string,
|
|
1069
|
+
const TTableName extends string,
|
|
1070
|
+
const TProperties extends Record<string, any>,
|
|
1071
|
+
const TPK extends (keyof TProperties)[] | undefined = undefined,
|
|
1072
|
+
const TBase = never,
|
|
1073
|
+
const TRepository = never,
|
|
1074
|
+
const TForceObject extends boolean = false,
|
|
1075
|
+
>(
|
|
1076
|
+
meta: EntityMetadataWithProperties<TName, TTableName, TProperties, TPK, TBase, TRepository, TForceObject>,
|
|
1077
|
+
): EntitySchemaWithMeta<
|
|
1078
|
+
TName,
|
|
1079
|
+
TTableName,
|
|
1080
|
+
InferEntityFromProperties<TProperties, TPK, TBase, TRepository, TForceObject>,
|
|
1081
|
+
TBase,
|
|
1082
|
+
TProperties
|
|
1083
|
+
>;
|
|
1084
|
+
/** Defines an entity schema for an existing class, combining the class with property builders. */
|
|
1085
|
+
export declare function defineEntity<
|
|
1086
|
+
const TEntity = any,
|
|
1087
|
+
const TProperties extends Record<string, any> = Record<string, any>,
|
|
1088
|
+
const TClassName extends string = string,
|
|
1089
|
+
const TTableName extends string = string,
|
|
1090
|
+
const TBase = never,
|
|
1091
|
+
const TClass extends EntityCtor = EntityCtor<TEntity>,
|
|
1092
|
+
>(
|
|
1093
|
+
meta: Omit<Partial<EntityMetadata<TEntity>>, 'properties' | 'extends' | 'className' | 'tableName' | 'hooks'> & {
|
|
581
1094
|
class: TClass;
|
|
582
1095
|
className?: TClassName;
|
|
583
1096
|
tableName?: TTableName;
|
|
584
1097
|
extends?: TBase;
|
|
585
1098
|
properties: TProperties | ((properties: PropertyBuilders) => TProperties);
|
|
586
1099
|
hooks?: DefineEntityHooks<TEntity>;
|
|
587
|
-
}
|
|
1100
|
+
},
|
|
1101
|
+
): EntitySchemaWithMeta<TClassName, TTableName, TEntity, TBase, TProperties, TClass>;
|
|
588
1102
|
export declare namespace defineEntity {
|
|
589
|
-
|
|
1103
|
+
var properties: PropertyBuilders;
|
|
590
1104
|
}
|
|
1105
|
+
/** Shorthand alias for `defineEntity.properties` - the property builders for use in `defineEntity()`. */
|
|
591
1106
|
export { propertyBuilders as p };
|
|
592
1107
|
type EntityHookValue<T, K extends keyof EventSubscriber<T>> = (keyof T | NonNullable<EventSubscriber<T>[K]>)[];
|
|
1108
|
+
/** Lifecycle hook definitions for entities created via `defineEntity()`. */
|
|
593
1109
|
export interface DefineEntityHooks<T = any> {
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
1110
|
+
onInit?: EntityHookValue<T, 'onInit'>;
|
|
1111
|
+
onLoad?: EntityHookValue<T, 'onLoad'>;
|
|
1112
|
+
beforeCreate?: EntityHookValue<T, 'beforeCreate'>;
|
|
1113
|
+
afterCreate?: EntityHookValue<T, 'afterCreate'>;
|
|
1114
|
+
beforeUpdate?: EntityHookValue<T, 'beforeUpdate'>;
|
|
1115
|
+
afterUpdate?: EntityHookValue<T, 'afterUpdate'>;
|
|
1116
|
+
beforeUpsert?: EntityHookValue<T, 'beforeUpsert'>;
|
|
1117
|
+
afterUpsert?: EntityHookValue<T, 'afterUpsert'>;
|
|
1118
|
+
beforeDelete?: EntityHookValue<T, 'beforeDelete'>;
|
|
1119
|
+
afterDelete?: EntityHookValue<T, 'afterDelete'>;
|
|
604
1120
|
}
|
|
605
1121
|
type PropertyValueType = PropertyOptions<any>['type'];
|
|
606
|
-
type InferPropertyValueType<T extends PropertyValueType> = T extends string
|
|
607
|
-
|
|
1122
|
+
type InferPropertyValueType<T extends PropertyValueType> = T extends string
|
|
1123
|
+
? InferTypeByString<T>
|
|
1124
|
+
: T extends NumberConstructor
|
|
1125
|
+
? number
|
|
1126
|
+
: T extends StringConstructor
|
|
1127
|
+
? string
|
|
1128
|
+
: T extends BooleanConstructor
|
|
1129
|
+
? boolean
|
|
1130
|
+
: T extends DateConstructor
|
|
1131
|
+
? Date
|
|
1132
|
+
: T extends ArrayConstructor
|
|
1133
|
+
? string[]
|
|
1134
|
+
: T extends Constructor<infer TType>
|
|
1135
|
+
? TType extends Type<infer TValue, any>
|
|
1136
|
+
? NonNullable<TValue>
|
|
1137
|
+
: TType
|
|
1138
|
+
: T extends Type<infer TValue, any>
|
|
1139
|
+
? NonNullable<TValue>
|
|
1140
|
+
: any;
|
|
1141
|
+
type InferTypeByString<T extends string> = T extends keyof typeof types
|
|
1142
|
+
? InferJSType<(typeof types)[T]>
|
|
1143
|
+
: InferColumnType<T>;
|
|
608
1144
|
type InferJSType<T> = T extends typeof Type<infer TValue, any> ? NonNullable<TValue> : never;
|
|
609
|
-
type InferColumnType<T extends string> = T extends
|
|
1145
|
+
type InferColumnType<T extends string> = T extends
|
|
1146
|
+
| 'int'
|
|
1147
|
+
| 'int4'
|
|
1148
|
+
| 'integer'
|
|
1149
|
+
| 'bigint'
|
|
1150
|
+
| 'int8'
|
|
1151
|
+
| 'int2'
|
|
1152
|
+
| 'tinyint'
|
|
1153
|
+
| 'smallint'
|
|
1154
|
+
| 'mediumint'
|
|
1155
|
+
? number
|
|
1156
|
+
: T extends 'double' | 'double precision' | 'real' | 'float8' | 'decimal' | 'numeric' | 'float' | 'float4'
|
|
1157
|
+
? number
|
|
1158
|
+
: T extends
|
|
1159
|
+
| 'datetime'
|
|
1160
|
+
| 'time'
|
|
1161
|
+
| 'time with time zone'
|
|
1162
|
+
| 'timestamp'
|
|
1163
|
+
| 'timestamp with time zone'
|
|
1164
|
+
| 'timetz'
|
|
1165
|
+
| 'timestamptz'
|
|
1166
|
+
| 'date'
|
|
1167
|
+
| 'interval'
|
|
1168
|
+
? Date
|
|
1169
|
+
: T extends
|
|
1170
|
+
| 'ObjectId'
|
|
1171
|
+
| 'objectId'
|
|
1172
|
+
| 'character varying'
|
|
1173
|
+
| 'varchar'
|
|
1174
|
+
| 'char'
|
|
1175
|
+
| 'character'
|
|
1176
|
+
| 'uuid'
|
|
1177
|
+
| 'text'
|
|
1178
|
+
| 'tinytext'
|
|
1179
|
+
| 'mediumtext'
|
|
1180
|
+
| 'longtext'
|
|
1181
|
+
| 'enum'
|
|
1182
|
+
? string
|
|
1183
|
+
: T extends 'boolean' | 'bool' | 'bit'
|
|
1184
|
+
? boolean
|
|
1185
|
+
: T extends 'blob' | 'tinyblob' | 'mediumblob' | 'longblob' | 'bytea'
|
|
1186
|
+
? Buffer
|
|
1187
|
+
: T extends 'point' | 'line' | 'lseg' | 'box' | 'circle' | 'path' | 'polygon' | 'geometry'
|
|
1188
|
+
? number[]
|
|
1189
|
+
: T extends 'tsvector' | 'tsquery'
|
|
1190
|
+
? string[]
|
|
1191
|
+
: T extends 'json' | 'jsonb'
|
|
1192
|
+
? any
|
|
1193
|
+
: any;
|
|
610
1194
|
type BaseEntityMethodKeys = 'toObject' | 'toPOJO' | 'serialize' | 'assign' | 'populate' | 'init' | 'toReference';
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
1195
|
+
/** Infers the entity type from a `defineEntity()` properties map, resolving builders, base classes, and primary keys. */
|
|
1196
|
+
export type InferEntityFromProperties<
|
|
1197
|
+
Properties extends Record<string, any>,
|
|
1198
|
+
PK extends (keyof Properties)[] | undefined = undefined,
|
|
1199
|
+
Base = never,
|
|
1200
|
+
Repository = never,
|
|
1201
|
+
ForceObject extends boolean = false,
|
|
1202
|
+
> = (IsNever<Base> extends true
|
|
1203
|
+
? {}
|
|
1204
|
+
: Base extends {
|
|
1205
|
+
toObject(...args: any[]): any;
|
|
1206
|
+
}
|
|
1207
|
+
? Pick<
|
|
1208
|
+
IWrappedEntity<
|
|
1209
|
+
{
|
|
1210
|
+
-readonly [K in keyof Properties]: InferBuilderValue<MaybeReturnType<Properties[K]>>;
|
|
1211
|
+
} & {
|
|
1212
|
+
[PrimaryKeyProp]?: InferCombinedPrimaryKey<Properties, PK, Base>;
|
|
1213
|
+
} & (IsNever<Repository> extends true
|
|
1214
|
+
? {}
|
|
1215
|
+
: {
|
|
1216
|
+
[EntityRepositoryType]?: Repository extends Constructor<infer R> ? R : Repository;
|
|
1217
|
+
}) &
|
|
1218
|
+
Omit<Base, typeof PrimaryKeyProp>
|
|
1219
|
+
>,
|
|
1220
|
+
BaseEntityMethodKeys
|
|
1221
|
+
>
|
|
1222
|
+
: {}) & {
|
|
1223
|
+
-readonly [K in keyof Properties]: InferBuilderValue<MaybeReturnType<Properties[K]>>;
|
|
621
1224
|
} & {
|
|
622
|
-
|
|
623
|
-
} & (IsNever<Repository> extends true
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
1225
|
+
[PrimaryKeyProp]?: InferCombinedPrimaryKey<Properties, PK, Base>;
|
|
1226
|
+
} & (IsNever<Repository> extends true
|
|
1227
|
+
? {}
|
|
1228
|
+
: {
|
|
1229
|
+
[EntityRepositoryType]?: Repository extends Constructor<infer R> ? R : Repository;
|
|
1230
|
+
}) &
|
|
1231
|
+
(IsNever<Base> extends true ? {} : Omit<Base, typeof PrimaryKeyProp>) &
|
|
1232
|
+
(ForceObject extends true
|
|
1233
|
+
? {
|
|
1234
|
+
[Config]?: DefineConfig<{
|
|
1235
|
+
forceObject: true;
|
|
1236
|
+
}>;
|
|
1237
|
+
}
|
|
1238
|
+
: {});
|
|
1239
|
+
type InferCombinedPrimaryKey<Properties extends Record<string, any>, PK, Base> = PK extends undefined
|
|
1240
|
+
? CombinePrimaryKeys<InferPrimaryKey<Properties>, ExtractBasePrimaryKey<Base>>
|
|
1241
|
+
: PK;
|
|
631
1242
|
type ExtractBasePrimaryKey<Base> = Base extends {
|
|
632
|
-
|
|
633
|
-
}
|
|
634
|
-
|
|
1243
|
+
[PrimaryKeyProp]?: infer BasePK;
|
|
1244
|
+
}
|
|
1245
|
+
? BasePK
|
|
1246
|
+
: never;
|
|
1247
|
+
type CombinePrimaryKeys<ChildPK, BasePK> = [ChildPK] extends [never]
|
|
1248
|
+
? BasePK
|
|
1249
|
+
: [BasePK] extends [never]
|
|
1250
|
+
? IsUnion<ChildPK> extends true
|
|
1251
|
+
? ChildPK[]
|
|
1252
|
+
: ChildPK
|
|
1253
|
+
: ChildPK | BasePK;
|
|
1254
|
+
/** Extracts the primary key property names from a properties map by finding builders with `primary: true`. */
|
|
635
1255
|
export type InferPrimaryKey<Properties extends Record<string, any>> = {
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
1256
|
+
[K in keyof Properties]: MaybeReturnType<Properties[K]> extends {
|
|
1257
|
+
'~options': {
|
|
1258
|
+
primary: true;
|
|
1259
|
+
};
|
|
1260
|
+
}
|
|
1261
|
+
? K
|
|
1262
|
+
: never;
|
|
641
1263
|
}[keyof Properties];
|
|
642
1264
|
type InferBuilderValue<Builder> = Builder extends {
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
}
|
|
1265
|
+
'~type'?: {
|
|
1266
|
+
value: infer Value;
|
|
1267
|
+
};
|
|
1268
|
+
'~options'?: infer Options;
|
|
1269
|
+
}
|
|
1270
|
+
? MaybeHidden<
|
|
1271
|
+
MaybeOpt<
|
|
1272
|
+
MaybeScalarRef<
|
|
1273
|
+
MaybeNullable<MaybeRelationRef<MaybeMapToPk<MaybeArray<Value, Options>, Options>, Options>, Options>,
|
|
1274
|
+
Options
|
|
1275
|
+
>,
|
|
1276
|
+
Options
|
|
1277
|
+
>,
|
|
1278
|
+
Options
|
|
1279
|
+
>
|
|
1280
|
+
: never;
|
|
648
1281
|
type MaybeArray<Value, Options> = Options extends {
|
|
649
|
-
|
|
650
|
-
}
|
|
1282
|
+
array: true;
|
|
1283
|
+
}
|
|
1284
|
+
? Value[]
|
|
1285
|
+
: Value;
|
|
651
1286
|
type MaybeMapToPk<Value, Options> = Options extends {
|
|
652
|
-
|
|
653
|
-
}
|
|
1287
|
+
mapToPk: true;
|
|
1288
|
+
}
|
|
1289
|
+
? Primary<Value>
|
|
1290
|
+
: Value;
|
|
654
1291
|
type MaybeNullable<Value, Options> = Options extends {
|
|
655
|
-
|
|
656
|
-
}
|
|
1292
|
+
nullable: true;
|
|
1293
|
+
}
|
|
1294
|
+
? Value | null | undefined
|
|
1295
|
+
: Value;
|
|
657
1296
|
type MaybeRelationRef<Value, Options> = Options extends {
|
|
658
|
-
|
|
659
|
-
}
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
1297
|
+
mapToPk: true;
|
|
1298
|
+
}
|
|
1299
|
+
? Value
|
|
1300
|
+
: Options extends {
|
|
1301
|
+
ref: true;
|
|
1302
|
+
kind: '1:1';
|
|
1303
|
+
}
|
|
1304
|
+
? Value extends object
|
|
1305
|
+
? Ref<Value>
|
|
1306
|
+
: never
|
|
1307
|
+
: Options extends {
|
|
1308
|
+
ref: true;
|
|
1309
|
+
kind: 'm:1';
|
|
1310
|
+
}
|
|
1311
|
+
? Value extends object
|
|
1312
|
+
? Ref<Value>
|
|
1313
|
+
: never
|
|
1314
|
+
: Options extends {
|
|
1315
|
+
kind: '1:m';
|
|
1316
|
+
}
|
|
1317
|
+
? Value extends object
|
|
1318
|
+
? Collection<Value>
|
|
1319
|
+
: never
|
|
1320
|
+
: Options extends {
|
|
1321
|
+
kind: 'm:n';
|
|
1322
|
+
}
|
|
1323
|
+
? Value extends object
|
|
1324
|
+
? Collection<Value>
|
|
1325
|
+
: never
|
|
1326
|
+
: Value;
|
|
670
1327
|
type MaybeScalarRef<Value, Options> = Options extends {
|
|
671
|
-
|
|
672
|
-
}
|
|
673
|
-
|
|
674
|
-
|
|
1328
|
+
kind: '1:1' | 'm:1' | '1:m' | 'm:n';
|
|
1329
|
+
}
|
|
1330
|
+
? Value
|
|
1331
|
+
: Options extends {
|
|
1332
|
+
ref: true;
|
|
1333
|
+
}
|
|
1334
|
+
? ScalarReference<Value>
|
|
1335
|
+
: Value;
|
|
675
1336
|
type MaybeOpt<Value, Options> = Options extends {
|
|
676
|
-
|
|
677
|
-
}
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
}
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
1337
|
+
mapToPk: true;
|
|
1338
|
+
}
|
|
1339
|
+
? Value extends Opt<infer OriginalValue>
|
|
1340
|
+
? OriginalValue
|
|
1341
|
+
: Value
|
|
1342
|
+
: Options extends
|
|
1343
|
+
| {
|
|
1344
|
+
autoincrement: true;
|
|
1345
|
+
}
|
|
1346
|
+
| {
|
|
1347
|
+
onCreate: Function;
|
|
1348
|
+
}
|
|
1349
|
+
| {
|
|
1350
|
+
default: string | string[] | number | number[] | boolean | null | Date | Raw;
|
|
1351
|
+
}
|
|
1352
|
+
| {
|
|
1353
|
+
defaultRaw: string;
|
|
1354
|
+
}
|
|
1355
|
+
| {
|
|
1356
|
+
persist: false;
|
|
1357
|
+
}
|
|
1358
|
+
| {
|
|
1359
|
+
version: true;
|
|
1360
|
+
}
|
|
1361
|
+
| {
|
|
1362
|
+
formula: string | ((...args: any[]) => any);
|
|
1363
|
+
}
|
|
1364
|
+
? Opt<NonNullable<Value>> | Extract<Value, null | undefined>
|
|
1365
|
+
: Value;
|
|
692
1366
|
type MaybeHidden<Value, Options> = Options extends {
|
|
693
|
-
|
|
694
|
-
}
|
|
1367
|
+
hidden: true;
|
|
1368
|
+
}
|
|
1369
|
+
? Hidden<NonNullable<Value>> | Extract<Value, null | undefined>
|
|
1370
|
+
: Value;
|
|
695
1371
|
type ValueOf<T extends Dictionary> = T[keyof T];
|
|
696
1372
|
type IsUnion<T, U = T> = T extends U ? ([U] extends [T] ? false : true) : false;
|