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