@mikro-orm/core 7.0.0-dev.259 → 7.0.0-dev.260
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/entity/defineEntity.d.ts +179 -47
- package/entity/defineEntity.js +20 -24
- package/package.json +1 -1
- package/utils/Utils.js +1 -1
package/entity/defineEntity.d.ts
CHANGED
|
@@ -16,11 +16,135 @@ type ExcludeKeys = 'entity' | 'items';
|
|
|
16
16
|
type BuilderKeys = Exclude<UniversalPropertyKeys, ExcludeKeys> | BuilderExtraKeys;
|
|
17
17
|
type IncludeKeysForProperty = Exclude<keyof PropertyOptions<any>, ExcludeKeys> | BuilderExtraKeys;
|
|
18
18
|
type IncludeKeysForEnumOptions = Exclude<keyof EnumOptions<any>, ExcludeKeys> | BuilderExtraKeys;
|
|
19
|
-
type IncludeKeysForEmbeddedOptions = Exclude<keyof EmbeddedOptions<any, any>, ExcludeKeys> | BuilderExtraKeys;
|
|
20
|
-
type IncludeKeysForManyToOneOptions = Exclude<keyof ManyToOneOptions<any, any>, ExcludeKeys> | BuilderExtraKeys;
|
|
21
19
|
type IncludeKeysForOneToManyOptions = Exclude<keyof OneToManyOptions<any, any>, ExcludeKeys> | BuilderExtraKeys;
|
|
22
|
-
type
|
|
23
|
-
|
|
20
|
+
type HasKind<Options, K extends string> = Options extends {
|
|
21
|
+
kind: infer X extends string;
|
|
22
|
+
} ? X extends K ? true : false : false;
|
|
23
|
+
/** Lightweight chain result type for property builders - reduces type instantiation cost by avoiding full class resolution. */
|
|
24
|
+
export interface PropertyChain<Value, Options> {
|
|
25
|
+
'~type'?: {
|
|
26
|
+
value: Value;
|
|
27
|
+
};
|
|
28
|
+
'~options': Options;
|
|
29
|
+
$type<T>(): PropertyChain<T, Options>;
|
|
30
|
+
$type<Runtime, Raw, Serialized = Raw>(): PropertyChain<IType<Runtime, Raw, Serialized>, Options>;
|
|
31
|
+
nullable(): PropertyChain<Value, Omit<Options, 'nullable'> & {
|
|
32
|
+
nullable: true;
|
|
33
|
+
}>;
|
|
34
|
+
ref(): PropertyChain<Value, Omit<Options, 'ref'> & {
|
|
35
|
+
ref: true;
|
|
36
|
+
}>;
|
|
37
|
+
primary(): PropertyChain<Value, Omit<Options, 'primary'> & {
|
|
38
|
+
primary: true;
|
|
39
|
+
}>;
|
|
40
|
+
hidden(): PropertyChain<Value, Omit<Options, 'hidden'> & {
|
|
41
|
+
hidden: true;
|
|
42
|
+
}>;
|
|
43
|
+
autoincrement(): PropertyChain<Value, Omit<Options, 'autoincrement'> & {
|
|
44
|
+
autoincrement: true;
|
|
45
|
+
}>;
|
|
46
|
+
autoincrement(autoincrement: false): PropertyChain<Value, Omit<Options, 'autoincrement'> & {
|
|
47
|
+
autoincrement: false;
|
|
48
|
+
}>;
|
|
49
|
+
persist(): PropertyChain<Value, Omit<Options, 'persist'> & {
|
|
50
|
+
persist: true;
|
|
51
|
+
}>;
|
|
52
|
+
persist(persist: false): PropertyChain<Value, Omit<Options, 'persist'> & {
|
|
53
|
+
persist: false;
|
|
54
|
+
}>;
|
|
55
|
+
version(): PropertyChain<Value, Omit<Options, 'version'> & {
|
|
56
|
+
version: true;
|
|
57
|
+
}>;
|
|
58
|
+
lazy(): PropertyChain<Value, Options>;
|
|
59
|
+
name<T extends string>(name: T): PropertyChain<Value, Omit<Options, 'fieldName'> & {
|
|
60
|
+
fieldName: T;
|
|
61
|
+
}>;
|
|
62
|
+
fieldName<T extends string>(fieldName: T): PropertyChain<Value, Omit<Options, 'fieldName'> & {
|
|
63
|
+
fieldName: T;
|
|
64
|
+
}>;
|
|
65
|
+
onCreate(onCreate: (entity: any, em: EntityManager) => Value): PropertyChain<Value, Options & {
|
|
66
|
+
onCreate: (...args: any[]) => any;
|
|
67
|
+
}>;
|
|
68
|
+
default(defaultValue: string | string[] | number | number[] | boolean | null | Date | Raw): PropertyChain<Value, Omit<Options, 'default'> & {
|
|
69
|
+
default: any;
|
|
70
|
+
}>;
|
|
71
|
+
defaultRaw(defaultRaw: string): PropertyChain<Value, Options & {
|
|
72
|
+
defaultRaw: string;
|
|
73
|
+
}>;
|
|
74
|
+
formula(formula: string | FormulaCallback<any>): PropertyChain<Value, Omit<Options, 'formula'> & {
|
|
75
|
+
formula: any;
|
|
76
|
+
}>;
|
|
77
|
+
onUpdate(onUpdate: (entity: any, em: EntityManager) => Value): PropertyChain<Value, Options>;
|
|
78
|
+
fieldNames(...fieldNames: string[]): PropertyChain<Value, Options>;
|
|
79
|
+
type(type: PropertyValueType): PropertyChain<Value, Options>;
|
|
80
|
+
runtimeType(runtimeType: string): PropertyChain<Value, Options>;
|
|
81
|
+
columnType(columnType: ColumnType | AnyString): PropertyChain<Value, Options>;
|
|
82
|
+
columnTypes(...columnTypes: (ColumnType | AnyString)[]): PropertyChain<Value, Options>;
|
|
83
|
+
length(length: number): PropertyChain<Value, Options>;
|
|
84
|
+
precision(precision: number): PropertyChain<Value, Options>;
|
|
85
|
+
scale(scale: number): PropertyChain<Value, Options>;
|
|
86
|
+
returning(returning?: boolean): PropertyChain<Value, Options>;
|
|
87
|
+
unsigned(unsigned?: boolean): PropertyChain<Value, Options>;
|
|
88
|
+
hydrate(hydrate?: boolean): PropertyChain<Value, Options>;
|
|
89
|
+
concurrencyCheck(concurrencyCheck?: boolean): PropertyChain<Value, Options>;
|
|
90
|
+
generated(generated: string | GeneratedColumnCallback<any>): PropertyChain<Value, Options>;
|
|
91
|
+
check(check: string | CheckCallback<any>): PropertyChain<Value, Options>;
|
|
92
|
+
setter(setter?: boolean): PropertyChain<Value, Options>;
|
|
93
|
+
getter(getter?: boolean): PropertyChain<Value, Options>;
|
|
94
|
+
getterName(getterName: string): PropertyChain<Value, Options>;
|
|
95
|
+
serializedPrimaryKey(serializedPrimaryKey?: boolean): PropertyChain<Value, Options>;
|
|
96
|
+
serializer(serializer: (value: Value, options?: SerializeOptions<any>) => any): PropertyChain<Value, Options>;
|
|
97
|
+
serializedName(serializedName: string): PropertyChain<Value, Options>;
|
|
98
|
+
groups(...groups: string[]): PropertyChain<Value, Options>;
|
|
99
|
+
customOrder(...customOrder: (string[] | number[] | boolean[])): PropertyChain<Value, Options>;
|
|
100
|
+
extra(extra: string): PropertyChain<Value, Options>;
|
|
101
|
+
ignoreSchemaChanges(...ignoreSchemaChanges: ('type' | 'extra' | 'default')[]): PropertyChain<Value, Options>;
|
|
102
|
+
index(index?: boolean | string): PropertyChain<Value, Options>;
|
|
103
|
+
unique(unique?: boolean | string): PropertyChain<Value, Options>;
|
|
104
|
+
comment(comment: string): PropertyChain<Value, Options>;
|
|
105
|
+
accessor(accessor?: string | boolean): PropertyChain<Value, Options>;
|
|
106
|
+
eager(eager?: boolean): HasKind<Options, 'm:1' | '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
|
|
107
|
+
cascade(...cascade: Cascade[]): HasKind<Options, 'm:1' | '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
|
|
108
|
+
strategy(strategy: LoadStrategy | `${LoadStrategy}`): HasKind<Options, 'm:1' | '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
|
|
109
|
+
filters(filters: FilterOptions): HasKind<Options, 'm:1' | '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
|
|
110
|
+
mappedBy(mappedBy: (keyof Value & string) | ((e: Value) => any)): HasKind<Options, '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
|
|
111
|
+
inversedBy(inversedBy: (keyof Value & string) | ((e: Value) => any)): HasKind<Options, 'm:1' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
|
|
112
|
+
owner(): HasKind<Options, '1:1' | 'm:n'> extends true ? PropertyChain<Value, Omit<Options, 'owner'> & {
|
|
113
|
+
owner: true;
|
|
114
|
+
}> : never;
|
|
115
|
+
mapToPk(): HasKind<Options, 'm:1' | '1:1'> extends true ? PropertyChain<Value, Omit<Options, 'mapToPk'> & {
|
|
116
|
+
mapToPk: true;
|
|
117
|
+
}> : never;
|
|
118
|
+
orphanRemoval(orphanRemoval?: boolean): HasKind<Options, '1:m' | '1:1'> extends true ? PropertyChain<Value, Options> : never;
|
|
119
|
+
discriminator(discriminator: string): HasKind<Options, 'm:1' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
|
|
120
|
+
discriminatorMap(discriminatorMap: Dictionary<string>): HasKind<Options, 'm:1' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
|
|
121
|
+
pivotTable(pivotTable: string): HasKind<Options, 'm:n'> extends true ? PropertyChain<Value, Options> : never;
|
|
122
|
+
pivotEntity(pivotEntity: () => EntityName): HasKind<Options, 'm:n'> extends true ? PropertyChain<Value, Options> : never;
|
|
123
|
+
fixedOrder(fixedOrder?: boolean): HasKind<Options, 'm:n'> extends true ? PropertyChain<Value, Options> : never;
|
|
124
|
+
fixedOrderColumn(fixedOrderColumn: string): HasKind<Options, 'm:n'> extends true ? PropertyChain<Value, Options> : never;
|
|
125
|
+
array(): HasKind<Options, 'embedded' | 'enum'> extends true ? PropertyChain<Value, Omit<Options, 'array'> & {
|
|
126
|
+
array: true;
|
|
127
|
+
}> : never;
|
|
128
|
+
prefix(prefix: string | boolean): HasKind<Options, 'embedded'> extends true ? PropertyChain<Value, Options> : never;
|
|
129
|
+
prefixMode(prefixMode: EmbeddedPrefixMode): HasKind<Options, 'embedded'> extends true ? PropertyChain<Value, Options> : never;
|
|
130
|
+
object(object?: boolean): HasKind<Options, 'embedded'> extends true ? PropertyChain<Value, Options> : never;
|
|
131
|
+
nativeEnumName(nativeEnumName: string): HasKind<Options, 'enum'> extends true ? PropertyChain<Value, Options> : never;
|
|
132
|
+
orderBy(...orderBy: QueryOrderMap<object>[]): HasKind<Options, 'm:1' | '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
|
|
133
|
+
where(...where: FilterQuery<object>[]): HasKind<Options, 'm:1' | '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
|
|
134
|
+
joinColumn(joinColumn: string): HasKind<Options, 'm:1' | '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
|
|
135
|
+
joinColumns(...joinColumns: string[]): HasKind<Options, 'm:1' | '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
|
|
136
|
+
inverseJoinColumn(inverseJoinColumn: string): HasKind<Options, 'm:1' | '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
|
|
137
|
+
inverseJoinColumns(...inverseJoinColumns: string[]): HasKind<Options, 'm:1' | '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
|
|
138
|
+
referenceColumnName(referenceColumnName: string): HasKind<Options, 'm:1' | '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
|
|
139
|
+
referencedColumnNames(...referencedColumnNames: string[]): HasKind<Options, 'm:1' | '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
|
|
140
|
+
ownColumns(...ownColumns: string[]): HasKind<Options, 'm:1' | '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
|
|
141
|
+
targetKey(targetKey: keyof Value & string): HasKind<Options, 'm:1' | '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
|
|
142
|
+
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;
|
|
143
|
+
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;
|
|
144
|
+
deferMode(deferMode: DeferMode | `${DeferMode}`): HasKind<Options, 'm:1' | '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
|
|
145
|
+
createForeignKeyConstraint(createForeignKeyConstraint?: boolean): HasKind<Options, 'm:1' | '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
|
|
146
|
+
foreignKeyName(foreignKeyName: string): HasKind<Options, 'm:1' | '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
|
|
147
|
+
}
|
|
24
148
|
/** @internal */
|
|
25
149
|
export declare class UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys extends BuilderKeys> implements Record<Exclude<UniversalPropertyKeys, ExcludeKeys>, any> {
|
|
26
150
|
'~options': Options;
|
|
@@ -100,8 +224,11 @@ export declare class UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys
|
|
|
100
224
|
/**
|
|
101
225
|
* Explicitly specify the auto increment of the primary key.
|
|
102
226
|
*/
|
|
103
|
-
autoincrement
|
|
104
|
-
autoincrement:
|
|
227
|
+
autoincrement(): Pick<UniversalPropertyOptionsBuilder<Value, Omit<Options, 'autoincrement'> & {
|
|
228
|
+
autoincrement: true;
|
|
229
|
+
}, IncludeKeys>, IncludeKeys>;
|
|
230
|
+
autoincrement(autoincrement: false): Pick<UniversalPropertyOptionsBuilder<Value, Omit<Options, 'autoincrement'> & {
|
|
231
|
+
autoincrement: false;
|
|
105
232
|
}, IncludeKeys>, IncludeKeys>;
|
|
106
233
|
/**
|
|
107
234
|
* Add the property to the `returning` statement.
|
|
@@ -150,8 +277,8 @@ export declare class UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys
|
|
|
150
277
|
/**
|
|
151
278
|
* Set column as nullable for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}.
|
|
152
279
|
*/
|
|
153
|
-
nullable
|
|
154
|
-
nullable:
|
|
280
|
+
nullable(): Pick<UniversalPropertyOptionsBuilder<Value, Omit<Options, 'nullable'> & {
|
|
281
|
+
nullable: true;
|
|
155
282
|
}, IncludeKeys>, IncludeKeys>;
|
|
156
283
|
/**
|
|
157
284
|
* Set column as unsigned for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}. (SQL only)
|
|
@@ -160,8 +287,11 @@ export declare class UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys
|
|
|
160
287
|
/**
|
|
161
288
|
* Set false to define {@link https://mikro-orm.io/docs/serializing#shadow-properties Shadow Property}.
|
|
162
289
|
*/
|
|
163
|
-
persist
|
|
164
|
-
persist:
|
|
290
|
+
persist(): Pick<UniversalPropertyOptionsBuilder<Value, Omit<Options, 'persist'> & {
|
|
291
|
+
persist: true;
|
|
292
|
+
}, IncludeKeys>, IncludeKeys>;
|
|
293
|
+
persist(persist: false): Pick<UniversalPropertyOptionsBuilder<Value, Omit<Options, 'persist'> & {
|
|
294
|
+
persist: false;
|
|
165
295
|
}, IncludeKeys>, IncludeKeys>;
|
|
166
296
|
/**
|
|
167
297
|
* Set false to disable hydration of this property. Useful for persisted getters.
|
|
@@ -170,20 +300,20 @@ export declare class UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys
|
|
|
170
300
|
/**
|
|
171
301
|
* 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.
|
|
172
302
|
*/
|
|
173
|
-
ref
|
|
174
|
-
ref:
|
|
303
|
+
ref(): UniversalPropertyOptionsBuilder<Value, Omit<Options, 'ref'> & {
|
|
304
|
+
ref: true;
|
|
175
305
|
}, IncludeKeys>;
|
|
176
306
|
/**
|
|
177
307
|
* Set to true to omit the property when {@link https://mikro-orm.io/docs/serializing Serializing}.
|
|
178
308
|
*/
|
|
179
|
-
hidden
|
|
180
|
-
hidden:
|
|
309
|
+
hidden(): Pick<UniversalPropertyOptionsBuilder<Value, Omit<Options, 'hidden'> & {
|
|
310
|
+
hidden: true;
|
|
181
311
|
}, IncludeKeys>, IncludeKeys>;
|
|
182
312
|
/**
|
|
183
313
|
* Set to true to enable {@link https://mikro-orm.io/docs/transactions#optimistic-locking Optimistic Locking} via version field. (SQL only)
|
|
184
314
|
*/
|
|
185
|
-
version
|
|
186
|
-
version:
|
|
315
|
+
version(): Pick<UniversalPropertyOptionsBuilder<Value, Omit<Options, 'version'> & {
|
|
316
|
+
version: true;
|
|
187
317
|
}, IncludeKeys>, IncludeKeys>;
|
|
188
318
|
/**
|
|
189
319
|
* Set to true to enable {@link https://mikro-orm.io/docs/transactions#optimistic-locking Optimistic Locking} via concurrency fields.
|
|
@@ -208,16 +338,14 @@ export declare class UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys
|
|
|
208
338
|
*
|
|
209
339
|
* @see https://mikro-orm.io/docs/defining-entities#lazy-scalar-properties
|
|
210
340
|
*/
|
|
211
|
-
lazy
|
|
212
|
-
ref: T;
|
|
213
|
-
}, IncludeKeys>, IncludeKeys>;
|
|
341
|
+
lazy(): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
214
342
|
/**
|
|
215
343
|
* Set true to define entity's unique primary key identifier.
|
|
216
344
|
*
|
|
217
345
|
* @see https://mikro-orm.io/docs/decorators#primarykey
|
|
218
346
|
*/
|
|
219
|
-
primary
|
|
220
|
-
primary:
|
|
347
|
+
primary(): Pick<UniversalPropertyOptionsBuilder<Value, Omit<Options, 'primary'> & {
|
|
348
|
+
primary: true;
|
|
221
349
|
}, IncludeKeys>, IncludeKeys>;
|
|
222
350
|
/**
|
|
223
351
|
* Set true to define the properties as setter. (virtual)
|
|
@@ -294,8 +422,8 @@ export declare class UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys
|
|
|
294
422
|
* @see https://mikro-orm.io/docs/defining-entities#sql-generated-columns
|
|
295
423
|
*/
|
|
296
424
|
ignoreSchemaChanges(...ignoreSchemaChanges: ('type' | 'extra' | 'default')[]): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
297
|
-
array
|
|
298
|
-
array:
|
|
425
|
+
array(): Pick<UniversalPropertyOptionsBuilder<Value, Omit<Options, 'array'> & {
|
|
426
|
+
array: true;
|
|
299
427
|
}, IncludeKeys>, IncludeKeys>;
|
|
300
428
|
/** for postgres, by default it uses text column with check constraint */
|
|
301
429
|
nativeEnumName(nativeEnumName: string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
@@ -309,8 +437,8 @@ export declare class UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys
|
|
|
309
437
|
/** Override the default loading strategy for this property. This option has precedence over the global `loadStrategy`, but can be overridden by `FindOptions.strategy`. */
|
|
310
438
|
strategy(strategy: LoadStrategy | `${LoadStrategy}`): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
311
439
|
/** 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. */
|
|
312
|
-
owner
|
|
313
|
-
owner:
|
|
440
|
+
owner(): Pick<UniversalPropertyOptionsBuilder<Value, Omit<Options, 'owner'> & {
|
|
441
|
+
owner: true;
|
|
314
442
|
}, IncludeKeys>, IncludeKeys>;
|
|
315
443
|
/** For polymorphic relations. Specifies the property name that stores the entity type discriminator. Defaults to the property name. */
|
|
316
444
|
discriminator(discriminator: string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
@@ -351,8 +479,8 @@ export declare class UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys
|
|
|
351
479
|
/** What to do when the reference to the target entity gets updated. */
|
|
352
480
|
updateRule(updateRule: 'cascade' | 'no action' | 'set null' | 'set default' | AnyString): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
353
481
|
/** Map this relation to the primary key value instead of an entity. */
|
|
354
|
-
mapToPk
|
|
355
|
-
mapToPk:
|
|
482
|
+
mapToPk(): Pick<UniversalPropertyOptionsBuilder<Value, Omit<Options, 'mapToPk'> & {
|
|
483
|
+
mapToPk: true;
|
|
356
484
|
}, IncludeKeys>, IncludeKeys>;
|
|
357
485
|
/** 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. */
|
|
358
486
|
deferMode(deferMode: DeferMode | `${DeferMode}`): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
|
|
@@ -390,17 +518,21 @@ declare const propertyBuilders: {
|
|
|
390
518
|
time: (length?: number) => UniversalPropertyOptionsBuilder<any, EmptyOptions, IncludeKeysForProperty>;
|
|
391
519
|
type: <T extends PropertyValueType>(type: T) => UniversalPropertyOptionsBuilder<InferPropertyValueType<T>, EmptyOptions, IncludeKeysForProperty>;
|
|
392
520
|
enum: <const T extends (number | string)[] | (() => Dictionary)>(items?: T) => UniversalPropertyOptionsBuilder<T extends () => Dictionary ? ValueOf<ReturnType<T>> : T extends (infer Value)[] ? Value : T, EmptyOptions, IncludeKeysForEnumOptions>;
|
|
393
|
-
embedded: <Target extends EntityTarget | EntityTarget[]>(target: Target) =>
|
|
394
|
-
|
|
521
|
+
embedded: <Target extends EntityTarget | EntityTarget[]>(target: Target) => PropertyChain<InferEntity<Target extends (infer T)[] ? T : Target>, EmptyOptions & {
|
|
522
|
+
kind: "embedded";
|
|
523
|
+
}>;
|
|
524
|
+
manyToMany: <Target extends EntityTarget>(target: Target) => PropertyChain<InferEntity<Target>, EmptyOptions & {
|
|
395
525
|
kind: "m:n";
|
|
396
|
-
}
|
|
397
|
-
manyToOne: <Target extends EntityTarget | EntityTarget[]>(target: Target) =>
|
|
526
|
+
}>;
|
|
527
|
+
manyToOne: <Target extends EntityTarget | EntityTarget[]>(target: Target) => PropertyChain<InferEntity<Target extends (infer T)[] ? T : Target>, EmptyOptions & {
|
|
398
528
|
kind: "m:1";
|
|
399
|
-
}
|
|
400
|
-
oneToMany: <Target extends EntityTarget>(target: Target) =>
|
|
401
|
-
|
|
529
|
+
}>;
|
|
530
|
+
oneToMany: <Target extends EntityTarget>(target: Target) => PropertyChain<InferEntity<Target>, EmptyOptions & {
|
|
531
|
+
kind: "1:m";
|
|
532
|
+
}>;
|
|
533
|
+
oneToOne: <Target extends EntityTarget | EntityTarget[]>(target: Target) => PropertyChain<InferEntity<Target extends (infer T)[] ? T : Target>, EmptyOptions & {
|
|
402
534
|
kind: "1:1";
|
|
403
|
-
}
|
|
535
|
+
}>;
|
|
404
536
|
date: () => UniversalPropertyOptionsBuilder<string, EmptyOptions, IncludeKeysForProperty>;
|
|
405
537
|
blob: () => UniversalPropertyOptionsBuilder<NonNullable<Buffer<ArrayBufferLike> | Uint8Array<ArrayBufferLike> | null>, EmptyOptions, IncludeKeysForProperty>;
|
|
406
538
|
uint8array: () => UniversalPropertyOptionsBuilder<Uint8Array<ArrayBufferLike>, EmptyOptions, IncludeKeysForProperty>;
|
|
@@ -476,17 +608,21 @@ export declare namespace defineEntity {
|
|
|
476
608
|
time: (length?: number) => UniversalPropertyOptionsBuilder<any, EmptyOptions, IncludeKeysForProperty>;
|
|
477
609
|
type: <T extends PropertyValueType>(type: T) => UniversalPropertyOptionsBuilder<InferPropertyValueType<T>, EmptyOptions, IncludeKeysForProperty>;
|
|
478
610
|
enum: <const T extends (number | string)[] | (() => Dictionary)>(items?: T) => UniversalPropertyOptionsBuilder<T extends () => Dictionary ? ValueOf<ReturnType<T>> : T extends (infer Value)[] ? Value : T, EmptyOptions, IncludeKeysForEnumOptions>;
|
|
479
|
-
embedded: <Target extends EntityTarget | EntityTarget[]>(target: Target) =>
|
|
480
|
-
|
|
611
|
+
embedded: <Target extends EntityTarget | EntityTarget[]>(target: Target) => PropertyChain<InferEntity<Target extends (infer T)[] ? T : Target>, EmptyOptions & {
|
|
612
|
+
kind: "embedded";
|
|
613
|
+
}>;
|
|
614
|
+
manyToMany: <Target extends EntityTarget>(target: Target) => PropertyChain<InferEntity<Target>, EmptyOptions & {
|
|
481
615
|
kind: "m:n";
|
|
482
|
-
}
|
|
483
|
-
manyToOne: <Target extends EntityTarget | EntityTarget[]>(target: Target) =>
|
|
616
|
+
}>;
|
|
617
|
+
manyToOne: <Target extends EntityTarget | EntityTarget[]>(target: Target) => PropertyChain<InferEntity<Target extends (infer T)[] ? T : Target>, EmptyOptions & {
|
|
484
618
|
kind: "m:1";
|
|
485
|
-
}
|
|
486
|
-
oneToMany: <Target extends EntityTarget>(target: Target) =>
|
|
487
|
-
|
|
619
|
+
}>;
|
|
620
|
+
oneToMany: <Target extends EntityTarget>(target: Target) => PropertyChain<InferEntity<Target>, EmptyOptions & {
|
|
621
|
+
kind: "1:m";
|
|
622
|
+
}>;
|
|
623
|
+
oneToOne: <Target extends EntityTarget | EntityTarget[]>(target: Target) => PropertyChain<InferEntity<Target extends (infer T)[] ? T : Target>, EmptyOptions & {
|
|
488
624
|
kind: "1:1";
|
|
489
|
-
}
|
|
625
|
+
}>;
|
|
490
626
|
date: () => UniversalPropertyOptionsBuilder<string, EmptyOptions, IncludeKeysForProperty>;
|
|
491
627
|
blob: () => UniversalPropertyOptionsBuilder<NonNullable<Buffer<ArrayBufferLike> | Uint8Array<ArrayBufferLike> | null>, EmptyOptions, IncludeKeysForProperty>;
|
|
492
628
|
uint8array: () => UniversalPropertyOptionsBuilder<Uint8Array<ArrayBufferLike>, EmptyOptions, IncludeKeysForProperty>;
|
|
@@ -563,8 +699,6 @@ type MaybeNullable<Value, Options> = Options extends {
|
|
|
563
699
|
} ? Value | null | undefined : Value;
|
|
564
700
|
type MaybeRelationRef<Value, Options> = Options extends {
|
|
565
701
|
mapToPk: true;
|
|
566
|
-
} ? Value : Options extends {
|
|
567
|
-
ref: false;
|
|
568
702
|
} ? Value : Options extends {
|
|
569
703
|
ref: true;
|
|
570
704
|
kind: '1:1';
|
|
@@ -577,8 +711,6 @@ type MaybeRelationRef<Value, Options> = Options extends {
|
|
|
577
711
|
kind: 'm:n';
|
|
578
712
|
} ? Value extends object ? Collection<Value> : never : Value;
|
|
579
713
|
type MaybeScalarRef<Value, Options> = Options extends {
|
|
580
|
-
ref: false;
|
|
581
|
-
} ? Value : Options extends {
|
|
582
714
|
kind: '1:1' | 'm:1' | '1:m' | 'm:n';
|
|
583
715
|
} ? Value : Options extends {
|
|
584
716
|
ref: true;
|
package/entity/defineEntity.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { types } from '../types/index.js';
|
|
2
2
|
import { EntitySchema } from '../metadata/EntitySchema.js';
|
|
3
|
+
// Parameter-level sync assertion lives in tests/defineEntity.test.ts to avoid
|
|
4
|
+
// instantiating the full builder class in production builds (~680 instantiations).
|
|
3
5
|
/** @internal */
|
|
4
6
|
export class UniversalPropertyOptionsBuilder {
|
|
5
7
|
'~options';
|
|
@@ -82,9 +84,6 @@ export class UniversalPropertyOptionsBuilder {
|
|
|
82
84
|
scale(scale) {
|
|
83
85
|
return this.assignOptions({ scale });
|
|
84
86
|
}
|
|
85
|
-
/**
|
|
86
|
-
* Explicitly specify the auto increment of the primary key.
|
|
87
|
-
*/
|
|
88
87
|
autoincrement(autoincrement = true) {
|
|
89
88
|
return this.assignOptions({ autoincrement });
|
|
90
89
|
}
|
|
@@ -143,8 +142,8 @@ export class UniversalPropertyOptionsBuilder {
|
|
|
143
142
|
/**
|
|
144
143
|
* Set column as nullable for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}.
|
|
145
144
|
*/
|
|
146
|
-
nullable(
|
|
147
|
-
return this.assignOptions({ nullable });
|
|
145
|
+
nullable() {
|
|
146
|
+
return this.assignOptions({ nullable: true });
|
|
148
147
|
}
|
|
149
148
|
/**
|
|
150
149
|
* Set column as unsigned for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}. (SQL only)
|
|
@@ -152,9 +151,6 @@ export class UniversalPropertyOptionsBuilder {
|
|
|
152
151
|
unsigned(unsigned = true) {
|
|
153
152
|
return this.assignOptions({ unsigned });
|
|
154
153
|
}
|
|
155
|
-
/**
|
|
156
|
-
* Set false to define {@link https://mikro-orm.io/docs/serializing#shadow-properties Shadow Property}.
|
|
157
|
-
*/
|
|
158
154
|
persist(persist = true) {
|
|
159
155
|
return this.assignOptions({ persist });
|
|
160
156
|
}
|
|
@@ -167,20 +163,20 @@ export class UniversalPropertyOptionsBuilder {
|
|
|
167
163
|
/**
|
|
168
164
|
* 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.
|
|
169
165
|
*/
|
|
170
|
-
ref(
|
|
171
|
-
return this.assignOptions({ ref });
|
|
166
|
+
ref() {
|
|
167
|
+
return this.assignOptions({ ref: true });
|
|
172
168
|
}
|
|
173
169
|
/**
|
|
174
170
|
* Set to true to omit the property when {@link https://mikro-orm.io/docs/serializing Serializing}.
|
|
175
171
|
*/
|
|
176
|
-
hidden(
|
|
177
|
-
return this.assignOptions({ hidden });
|
|
172
|
+
hidden() {
|
|
173
|
+
return this.assignOptions({ hidden: true });
|
|
178
174
|
}
|
|
179
175
|
/**
|
|
180
176
|
* Set to true to enable {@link https://mikro-orm.io/docs/transactions#optimistic-locking Optimistic Locking} via version field. (SQL only)
|
|
181
177
|
*/
|
|
182
|
-
version(
|
|
183
|
-
return this.assignOptions({ version });
|
|
178
|
+
version() {
|
|
179
|
+
return this.assignOptions({ version: true });
|
|
184
180
|
}
|
|
185
181
|
/**
|
|
186
182
|
* Set to true to enable {@link https://mikro-orm.io/docs/transactions#optimistic-locking Optimistic Locking} via concurrency fields.
|
|
@@ -213,16 +209,16 @@ export class UniversalPropertyOptionsBuilder {
|
|
|
213
209
|
*
|
|
214
210
|
* @see https://mikro-orm.io/docs/defining-entities#lazy-scalar-properties
|
|
215
211
|
*/
|
|
216
|
-
lazy(
|
|
217
|
-
return this.assignOptions({ lazy
|
|
212
|
+
lazy() {
|
|
213
|
+
return this.assignOptions({ lazy: true });
|
|
218
214
|
}
|
|
219
215
|
/**
|
|
220
216
|
* Set true to define entity's unique primary key identifier.
|
|
221
217
|
*
|
|
222
218
|
* @see https://mikro-orm.io/docs/decorators#primarykey
|
|
223
219
|
*/
|
|
224
|
-
primary(
|
|
225
|
-
return this.assignOptions({ primary });
|
|
220
|
+
primary() {
|
|
221
|
+
return this.assignOptions({ primary: true });
|
|
226
222
|
}
|
|
227
223
|
/**
|
|
228
224
|
* Set true to define the properties as setter. (virtual)
|
|
@@ -321,8 +317,8 @@ export class UniversalPropertyOptionsBuilder {
|
|
|
321
317
|
ignoreSchemaChanges(...ignoreSchemaChanges) {
|
|
322
318
|
return this.assignOptions({ ignoreSchemaChanges });
|
|
323
319
|
}
|
|
324
|
-
array(
|
|
325
|
-
return this.assignOptions({ array });
|
|
320
|
+
array() {
|
|
321
|
+
return this.assignOptions({ array: true });
|
|
326
322
|
}
|
|
327
323
|
/** for postgres, by default it uses text column with check constraint */
|
|
328
324
|
nativeEnumName(nativeEnumName) {
|
|
@@ -350,8 +346,8 @@ export class UniversalPropertyOptionsBuilder {
|
|
|
350
346
|
return this.assignOptions({ strategy });
|
|
351
347
|
}
|
|
352
348
|
/** 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. */
|
|
353
|
-
owner(
|
|
354
|
-
return this.assignOptions({ owner });
|
|
349
|
+
owner() {
|
|
350
|
+
return this.assignOptions({ owner: true });
|
|
355
351
|
}
|
|
356
352
|
/** For polymorphic relations. Specifies the property name that stores the entity type discriminator. Defaults to the property name. */
|
|
357
353
|
discriminator(discriminator) {
|
|
@@ -430,8 +426,8 @@ export class UniversalPropertyOptionsBuilder {
|
|
|
430
426
|
return this.assignOptions({ updateRule });
|
|
431
427
|
}
|
|
432
428
|
/** Map this relation to the primary key value instead of an entity. */
|
|
433
|
-
mapToPk(
|
|
434
|
-
return this.assignOptions({ mapToPk });
|
|
429
|
+
mapToPk() {
|
|
430
|
+
return this.assignOptions({ mapToPk: true });
|
|
435
431
|
}
|
|
436
432
|
/** 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. */
|
|
437
433
|
deferMode(deferMode) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "7.0.0-dev.
|
|
4
|
+
"version": "7.0.0-dev.260",
|
|
5
5
|
"description": "TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, PostgreSQL and SQLite databases as well as usage with vanilla JavaScript.",
|
|
6
6
|
"exports": {
|
|
7
7
|
"./package.json": "./package.json",
|
package/utils/Utils.js
CHANGED
|
@@ -123,7 +123,7 @@ export function parseJsonSafe(value) {
|
|
|
123
123
|
}
|
|
124
124
|
export class Utils {
|
|
125
125
|
static PK_SEPARATOR = '~~~';
|
|
126
|
-
static #ORM_VERSION = '7.0.0-dev.
|
|
126
|
+
static #ORM_VERSION = '7.0.0-dev.260';
|
|
127
127
|
/**
|
|
128
128
|
* Checks if the argument is instance of `Object`. Returns false for arrays.
|
|
129
129
|
*/
|