@mikro-orm/core 7.0.0-dev.32 → 7.0.0-dev.321
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 +71 -63
- package/EntityManager.js +365 -283
- package/MikroORM.d.ts +44 -35
- package/MikroORM.js +109 -142
- package/README.md +7 -4
- package/cache/FileCacheAdapter.d.ts +1 -2
- package/cache/FileCacheAdapter.js +19 -14
- package/cache/GeneratedCacheAdapter.d.ts +0 -1
- package/cache/GeneratedCacheAdapter.js +0 -2
- package/cache/index.d.ts +1 -2
- package/cache/index.js +0 -2
- package/connections/Connection.d.ts +12 -5
- package/connections/Connection.js +37 -15
- package/drivers/DatabaseDriver.d.ts +25 -18
- package/drivers/DatabaseDriver.js +144 -45
- package/drivers/IDatabaseDriver.d.ts +118 -23
- package/entity/BaseEntity.d.ts +63 -4
- package/entity/BaseEntity.js +0 -3
- package/entity/Collection.d.ts +101 -29
- package/entity/Collection.js +473 -115
- package/entity/EntityAssigner.js +37 -25
- package/entity/EntityFactory.d.ts +7 -1
- package/entity/EntityFactory.js +116 -64
- package/entity/EntityHelper.d.ts +2 -2
- package/entity/EntityHelper.js +69 -27
- package/entity/EntityLoader.d.ts +11 -10
- package/entity/EntityLoader.js +264 -102
- package/entity/EntityRepository.d.ts +28 -8
- package/entity/EntityRepository.js +8 -2
- package/entity/PolymorphicRef.d.ts +12 -0
- package/entity/PolymorphicRef.js +18 -0
- package/entity/Reference.d.ts +2 -6
- package/entity/Reference.js +52 -19
- package/entity/WrappedEntity.d.ts +3 -8
- package/entity/WrappedEntity.js +6 -7
- package/entity/defineEntity.d.ts +525 -311
- package/entity/defineEntity.js +134 -290
- package/entity/index.d.ts +2 -2
- package/entity/index.js +2 -2
- package/entity/utils.d.ts +6 -1
- package/entity/utils.js +46 -11
- package/entity/validators.d.ts +11 -0
- package/entity/validators.js +66 -0
- package/enums.d.ts +8 -6
- package/enums.js +13 -17
- package/errors.d.ts +20 -10
- package/errors.js +63 -31
- package/events/EventManager.d.ts +2 -1
- package/events/EventManager.js +24 -13
- package/events/index.d.ts +1 -1
- package/events/index.js +0 -1
- package/exceptions.js +9 -2
- package/hydration/Hydrator.js +1 -2
- package/hydration/ObjectHydrator.d.ts +4 -4
- package/hydration/ObjectHydrator.js +105 -46
- package/index.d.ts +2 -2
- package/index.js +1 -2
- package/logging/DefaultLogger.d.ts +1 -1
- package/logging/DefaultLogger.js +3 -4
- package/logging/SimpleLogger.d.ts +1 -1
- package/logging/colors.d.ts +1 -1
- package/logging/colors.js +5 -7
- package/logging/index.d.ts +2 -1
- package/logging/index.js +1 -1
- package/logging/inspect.d.ts +2 -0
- package/logging/inspect.js +11 -0
- package/metadata/EntitySchema.d.ts +47 -23
- package/metadata/EntitySchema.js +103 -34
- package/metadata/MetadataDiscovery.d.ts +64 -9
- package/metadata/MetadataDiscovery.js +867 -354
- package/metadata/MetadataProvider.d.ts +11 -2
- package/metadata/MetadataProvider.js +71 -2
- package/metadata/MetadataStorage.d.ts +13 -11
- package/metadata/MetadataStorage.js +72 -41
- package/metadata/MetadataValidator.d.ts +32 -9
- package/metadata/MetadataValidator.js +214 -44
- package/metadata/discover-entities.d.ts +5 -0
- package/metadata/discover-entities.js +40 -0
- package/metadata/index.d.ts +1 -1
- package/metadata/index.js +0 -1
- package/metadata/types.d.ts +577 -0
- package/metadata/types.js +1 -0
- package/naming-strategy/AbstractNamingStrategy.d.ts +16 -4
- package/naming-strategy/AbstractNamingStrategy.js +26 -5
- package/naming-strategy/EntityCaseNamingStrategy.d.ts +3 -3
- package/naming-strategy/EntityCaseNamingStrategy.js +6 -5
- package/naming-strategy/MongoNamingStrategy.d.ts +3 -3
- package/naming-strategy/MongoNamingStrategy.js +6 -6
- package/naming-strategy/NamingStrategy.d.ts +28 -4
- package/naming-strategy/UnderscoreNamingStrategy.d.ts +3 -3
- package/naming-strategy/UnderscoreNamingStrategy.js +6 -6
- package/naming-strategy/index.d.ts +1 -1
- package/naming-strategy/index.js +0 -1
- package/not-supported.d.ts +2 -0
- package/not-supported.js +8 -0
- package/package.json +47 -36
- package/platforms/ExceptionConverter.js +1 -1
- package/platforms/Platform.d.ts +33 -15
- package/platforms/Platform.js +125 -69
- package/serialization/EntitySerializer.d.ts +6 -3
- package/serialization/EntitySerializer.js +53 -29
- package/serialization/EntityTransformer.js +33 -21
- package/serialization/SerializationContext.d.ts +6 -6
- package/serialization/SerializationContext.js +4 -4
- package/types/ArrayType.d.ts +1 -1
- package/types/ArrayType.js +2 -3
- package/types/BigIntType.js +1 -1
- package/types/BlobType.d.ts +0 -1
- package/types/BlobType.js +0 -3
- package/types/BooleanType.d.ts +1 -0
- package/types/BooleanType.js +3 -0
- package/types/DecimalType.js +2 -2
- package/types/DoubleType.js +1 -1
- package/types/EnumArrayType.js +1 -2
- package/types/JsonType.d.ts +1 -1
- package/types/JsonType.js +7 -2
- package/types/TinyIntType.js +1 -1
- package/types/Type.d.ts +2 -4
- package/types/Type.js +3 -3
- package/types/Uint8ArrayType.d.ts +0 -1
- package/types/Uint8ArrayType.js +1 -4
- package/types/UuidType.d.ts +2 -0
- package/types/UuidType.js +14 -2
- package/types/index.d.ts +3 -2
- package/typings.d.ts +427 -170
- package/typings.js +100 -45
- package/unit-of-work/ChangeSet.d.ts +4 -6
- package/unit-of-work/ChangeSet.js +8 -9
- package/unit-of-work/ChangeSetComputer.d.ts +3 -8
- package/unit-of-work/ChangeSetComputer.js +49 -26
- package/unit-of-work/ChangeSetPersister.d.ts +13 -12
- package/unit-of-work/ChangeSetPersister.js +107 -44
- package/unit-of-work/CommitOrderCalculator.d.ts +12 -10
- package/unit-of-work/CommitOrderCalculator.js +17 -15
- package/unit-of-work/IdentityMap.d.ts +12 -0
- package/unit-of-work/IdentityMap.js +39 -1
- package/unit-of-work/UnitOfWork.d.ts +34 -4
- package/unit-of-work/UnitOfWork.js +294 -107
- package/utils/AbstractMigrator.d.ts +101 -0
- package/utils/AbstractMigrator.js +303 -0
- package/utils/AbstractSchemaGenerator.d.ts +5 -5
- package/utils/AbstractSchemaGenerator.js +30 -18
- package/utils/AsyncContext.d.ts +6 -0
- package/utils/AsyncContext.js +42 -0
- package/utils/Configuration.d.ts +796 -211
- package/utils/Configuration.js +160 -197
- package/utils/ConfigurationLoader.d.ts +1 -52
- package/utils/ConfigurationLoader.js +1 -330
- package/utils/Cursor.d.ts +0 -3
- package/utils/Cursor.js +29 -14
- package/utils/DataloaderUtils.d.ts +10 -5
- package/utils/DataloaderUtils.js +42 -22
- package/utils/EntityComparator.d.ts +16 -9
- package/utils/EntityComparator.js +202 -96
- package/utils/QueryHelper.d.ts +34 -7
- package/utils/QueryHelper.js +183 -72
- package/utils/RawQueryFragment.d.ts +28 -34
- package/utils/RawQueryFragment.js +37 -72
- package/utils/RequestContext.js +2 -2
- package/utils/TransactionContext.js +2 -2
- package/utils/TransactionManager.js +11 -7
- package/utils/Utils.d.ts +16 -127
- package/utils/Utils.js +106 -401
- package/utils/clone.js +13 -23
- package/utils/env-vars.d.ts +7 -0
- package/utils/env-vars.js +98 -0
- package/utils/fs-utils.d.ts +34 -0
- package/utils/fs-utils.js +193 -0
- package/utils/index.d.ts +1 -3
- package/utils/index.js +1 -3
- package/utils/upsert-utils.d.ts +9 -4
- package/utils/upsert-utils.js +51 -5
- package/decorators/Check.d.ts +0 -3
- package/decorators/Check.js +0 -13
- package/decorators/CreateRequestContext.d.ts +0 -3
- package/decorators/CreateRequestContext.js +0 -32
- package/decorators/Embeddable.d.ts +0 -8
- package/decorators/Embeddable.js +0 -11
- package/decorators/Embedded.d.ts +0 -12
- package/decorators/Embedded.js +0 -18
- package/decorators/Entity.d.ts +0 -33
- package/decorators/Entity.js +0 -12
- package/decorators/Enum.d.ts +0 -9
- package/decorators/Enum.js +0 -16
- package/decorators/Filter.d.ts +0 -2
- package/decorators/Filter.js +0 -8
- package/decorators/Formula.d.ts +0 -4
- package/decorators/Formula.js +0 -15
- package/decorators/Indexed.d.ts +0 -19
- package/decorators/Indexed.js +0 -20
- package/decorators/ManyToMany.d.ts +0 -42
- package/decorators/ManyToMany.js +0 -14
- package/decorators/ManyToOne.d.ts +0 -34
- package/decorators/ManyToOne.js +0 -14
- package/decorators/OneToMany.d.ts +0 -28
- package/decorators/OneToMany.js +0 -17
- package/decorators/OneToOne.d.ts +0 -28
- package/decorators/OneToOne.js +0 -7
- package/decorators/PrimaryKey.d.ts +0 -8
- package/decorators/PrimaryKey.js +0 -20
- package/decorators/Property.d.ts +0 -250
- package/decorators/Property.js +0 -32
- package/decorators/Transactional.d.ts +0 -14
- package/decorators/Transactional.js +0 -28
- package/decorators/hooks.d.ts +0 -16
- package/decorators/hooks.js +0 -47
- package/decorators/index.d.ts +0 -17
- package/decorators/index.js +0 -17
- package/entity/ArrayCollection.d.ts +0 -118
- package/entity/ArrayCollection.js +0 -407
- package/entity/EntityValidator.d.ts +0 -19
- package/entity/EntityValidator.js +0 -150
- package/metadata/ReflectMetadataProvider.d.ts +0 -8
- package/metadata/ReflectMetadataProvider.js +0 -44
- package/utils/resolveContextProvider.d.ts +0 -10
- package/utils/resolveContextProvider.js +0 -28
package/entity/defineEntity.js
CHANGED
|
@@ -1,17 +1,25 @@
|
|
|
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
|
-
export class
|
|
6
|
+
export class UniversalPropertyOptionsBuilder {
|
|
5
7
|
'~options';
|
|
6
8
|
'~type';
|
|
7
9
|
constructor(options) {
|
|
8
10
|
this['~options'] = options;
|
|
9
11
|
}
|
|
12
|
+
assignOptions(options) {
|
|
13
|
+
return new UniversalPropertyOptionsBuilder({ ...this['~options'], ...options });
|
|
14
|
+
}
|
|
15
|
+
$type() {
|
|
16
|
+
return this.assignOptions({});
|
|
17
|
+
}
|
|
10
18
|
/**
|
|
11
19
|
* Alias for `fieldName`.
|
|
12
20
|
*/
|
|
13
21
|
name(name) {
|
|
14
|
-
return
|
|
22
|
+
return this.assignOptions({ name });
|
|
15
23
|
}
|
|
16
24
|
/**
|
|
17
25
|
* Specify database column name for this property.
|
|
@@ -19,7 +27,7 @@ export class PropertyOptionsBuilder {
|
|
|
19
27
|
* @see https://mikro-orm.io/docs/naming-strategy
|
|
20
28
|
*/
|
|
21
29
|
fieldName(fieldName) {
|
|
22
|
-
return
|
|
30
|
+
return this.assignOptions({ fieldName });
|
|
23
31
|
}
|
|
24
32
|
/**
|
|
25
33
|
* Specify database column names for this property.
|
|
@@ -28,19 +36,19 @@ export class PropertyOptionsBuilder {
|
|
|
28
36
|
* @see https://mikro-orm.io/docs/naming-strategy
|
|
29
37
|
*/
|
|
30
38
|
fieldNames(...fieldNames) {
|
|
31
|
-
return
|
|
39
|
+
return this.assignOptions({ fieldNames });
|
|
32
40
|
}
|
|
33
41
|
/**
|
|
34
42
|
* 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)
|
|
35
43
|
*/
|
|
36
44
|
columnType(columnType) {
|
|
37
|
-
return
|
|
45
|
+
return this.assignOptions({ columnType });
|
|
38
46
|
}
|
|
39
47
|
/**
|
|
40
48
|
* 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)
|
|
41
49
|
*/
|
|
42
50
|
columnTypes(...columnTypes) {
|
|
43
|
-
return
|
|
51
|
+
return this.assignOptions({ columnTypes });
|
|
44
52
|
}
|
|
45
53
|
/**
|
|
46
54
|
* Explicitly specify the runtime type.
|
|
@@ -49,72 +57,73 @@ export class PropertyOptionsBuilder {
|
|
|
49
57
|
* @see https://mikro-orm.io/docs/custom-types
|
|
50
58
|
*/
|
|
51
59
|
type(type) {
|
|
52
|
-
return
|
|
60
|
+
return this.assignOptions({ type });
|
|
53
61
|
}
|
|
54
62
|
/**
|
|
55
63
|
* 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`.
|
|
56
64
|
* 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`.
|
|
57
65
|
*/
|
|
58
66
|
runtimeType(runtimeType) {
|
|
59
|
-
return
|
|
67
|
+
return this.assignOptions({ runtimeType });
|
|
60
68
|
}
|
|
61
69
|
/**
|
|
62
70
|
* 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)
|
|
63
71
|
*/
|
|
64
72
|
length(length) {
|
|
65
|
-
return
|
|
73
|
+
return this.assignOptions({ length });
|
|
66
74
|
}
|
|
67
75
|
/**
|
|
68
76
|
* Set precision of database column to represent the number of significant digits. (SQL only)
|
|
69
77
|
*/
|
|
70
78
|
precision(precision) {
|
|
71
|
-
return
|
|
79
|
+
return this.assignOptions({ precision });
|
|
72
80
|
}
|
|
73
81
|
/**
|
|
74
82
|
* Set scale of database column to represents the number of digits after the decimal point. (SQL only)
|
|
75
83
|
*/
|
|
76
84
|
scale(scale) {
|
|
77
|
-
return
|
|
85
|
+
return this.assignOptions({ scale });
|
|
78
86
|
}
|
|
79
|
-
/**
|
|
80
|
-
* Explicitly specify the auto increment of the primary key.
|
|
81
|
-
*/
|
|
82
87
|
autoincrement(autoincrement = true) {
|
|
83
|
-
return
|
|
88
|
+
return this.assignOptions({ autoincrement });
|
|
84
89
|
}
|
|
85
90
|
/**
|
|
86
91
|
* Add the property to the `returning` statement.
|
|
87
92
|
*/
|
|
88
93
|
returning(returning = true) {
|
|
89
|
-
return
|
|
94
|
+
return this.assignOptions({ returning });
|
|
90
95
|
}
|
|
91
96
|
/**
|
|
92
97
|
* Automatically set the property value when entity gets created, executed during flush operation.
|
|
93
|
-
* @param entity
|
|
94
98
|
*/
|
|
95
99
|
onCreate(onCreate) {
|
|
96
|
-
return
|
|
100
|
+
return this.assignOptions({ onCreate });
|
|
97
101
|
}
|
|
98
102
|
/**
|
|
99
103
|
* Automatically update the property value every time entity gets updated, executed during flush operation.
|
|
100
|
-
* @param entity
|
|
101
104
|
*/
|
|
102
105
|
onUpdate(onUpdate) {
|
|
103
|
-
return
|
|
106
|
+
return this.assignOptions({ onUpdate });
|
|
104
107
|
}
|
|
105
108
|
/**
|
|
106
109
|
* Specify default column value for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}.
|
|
107
110
|
* This is a runtime value, assignable to the entity property. (SQL only)
|
|
108
111
|
*/
|
|
109
112
|
default(defaultValue) {
|
|
110
|
-
return
|
|
113
|
+
return this.assignOptions({ default: defaultValue });
|
|
111
114
|
}
|
|
112
115
|
/**
|
|
113
116
|
* Specify SQL functions for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}. (SQL only)
|
|
114
117
|
* Since v4 you should use defaultRaw for SQL functions. e.g. now()
|
|
115
118
|
*/
|
|
116
119
|
defaultRaw(defaultRaw) {
|
|
117
|
-
return
|
|
120
|
+
return this.assignOptions({ defaultRaw });
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Allow controlling `filters` option. This will be overridden with `em.fork` or `FindOptions` if provided.
|
|
124
|
+
*/
|
|
125
|
+
filters(filters) {
|
|
126
|
+
return this.assignOptions({ filters });
|
|
118
127
|
}
|
|
119
128
|
/**
|
|
120
129
|
* Set to map some SQL snippet for the entity.
|
|
@@ -122,81 +131,70 @@ export class PropertyOptionsBuilder {
|
|
|
122
131
|
* @see https://mikro-orm.io/docs/defining-entities#formulas Formulas
|
|
123
132
|
*/
|
|
124
133
|
formula(formula) {
|
|
125
|
-
return
|
|
134
|
+
return this.assignOptions({ formula });
|
|
126
135
|
}
|
|
127
136
|
/**
|
|
128
137
|
* For generated columns. This will be appended to the column type after the `generated always` clause.
|
|
129
138
|
*/
|
|
130
139
|
generated(generated) {
|
|
131
|
-
return
|
|
140
|
+
return this.assignOptions({ generated });
|
|
132
141
|
}
|
|
133
142
|
/**
|
|
134
143
|
* Set column as nullable for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}.
|
|
135
144
|
*/
|
|
136
|
-
nullable(
|
|
137
|
-
return
|
|
145
|
+
nullable() {
|
|
146
|
+
return this.assignOptions({ nullable: true });
|
|
138
147
|
}
|
|
139
148
|
/**
|
|
140
149
|
* Set column as unsigned for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}. (SQL only)
|
|
141
150
|
*/
|
|
142
151
|
unsigned(unsigned = true) {
|
|
143
|
-
return
|
|
152
|
+
return this.assignOptions({ unsigned });
|
|
144
153
|
}
|
|
145
|
-
/**
|
|
146
|
-
* Set false to define {@link https://mikro-orm.io/docs/serializing#shadow-properties Shadow Property}.
|
|
147
|
-
*/
|
|
148
154
|
persist(persist = true) {
|
|
149
|
-
return
|
|
155
|
+
return this.assignOptions({ persist });
|
|
150
156
|
}
|
|
151
157
|
/**
|
|
152
158
|
* Set false to disable hydration of this property. Useful for persisted getters.
|
|
153
159
|
*/
|
|
154
160
|
hydrate(hydrate = true) {
|
|
155
|
-
return
|
|
161
|
+
return this.assignOptions({ hydrate });
|
|
156
162
|
}
|
|
157
163
|
/**
|
|
158
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.
|
|
159
165
|
*/
|
|
160
|
-
ref(
|
|
161
|
-
return
|
|
162
|
-
}
|
|
163
|
-
/**
|
|
164
|
-
* Set false to disable change tracking on a property level.
|
|
165
|
-
*
|
|
166
|
-
* @see https://mikro-orm.io/docs/unit-of-work#change-tracking-and-performance-considerations
|
|
167
|
-
*/
|
|
168
|
-
trackChanges(trackChanges = true) {
|
|
169
|
-
return new PropertyOptionsBuilder({ ...this['~options'], trackChanges });
|
|
166
|
+
ref() {
|
|
167
|
+
return this.assignOptions({ ref: true });
|
|
170
168
|
}
|
|
171
169
|
/**
|
|
172
170
|
* Set to true to omit the property when {@link https://mikro-orm.io/docs/serializing Serializing}.
|
|
173
171
|
*/
|
|
174
|
-
hidden(
|
|
175
|
-
return
|
|
172
|
+
hidden() {
|
|
173
|
+
return this.assignOptions({ hidden: true });
|
|
176
174
|
}
|
|
177
175
|
/**
|
|
178
176
|
* Set to true to enable {@link https://mikro-orm.io/docs/transactions#optimistic-locking Optimistic Locking} via version field. (SQL only)
|
|
179
177
|
*/
|
|
180
|
-
version(
|
|
181
|
-
return
|
|
178
|
+
version() {
|
|
179
|
+
return this.assignOptions({ version: true });
|
|
182
180
|
}
|
|
183
181
|
/**
|
|
184
182
|
* Set to true to enable {@link https://mikro-orm.io/docs/transactions#optimistic-locking Optimistic Locking} via concurrency fields.
|
|
185
183
|
*/
|
|
186
184
|
concurrencyCheck(concurrencyCheck = true) {
|
|
187
|
-
return
|
|
185
|
+
return this.assignOptions({ concurrencyCheck });
|
|
188
186
|
}
|
|
189
187
|
/**
|
|
190
188
|
* Explicitly specify index on a property.
|
|
191
189
|
*/
|
|
192
190
|
index(index = true) {
|
|
193
|
-
return
|
|
191
|
+
return this.assignOptions({ index });
|
|
194
192
|
}
|
|
195
193
|
/**
|
|
196
194
|
* Set column as unique for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}. (SQL only)
|
|
197
195
|
*/
|
|
198
196
|
unique(unique = true) {
|
|
199
|
-
return
|
|
197
|
+
return this.assignOptions({ unique });
|
|
200
198
|
}
|
|
201
199
|
/**
|
|
202
200
|
* Specify column with check constraints. (Postgres driver only)
|
|
@@ -204,23 +202,23 @@ export class PropertyOptionsBuilder {
|
|
|
204
202
|
* @see https://mikro-orm.io/docs/defining-entities#check-constraints
|
|
205
203
|
*/
|
|
206
204
|
check(check) {
|
|
207
|
-
return
|
|
205
|
+
return this.assignOptions({ check });
|
|
208
206
|
}
|
|
209
207
|
/**
|
|
210
208
|
* Set to omit the property from the select clause for lazy loading.
|
|
211
209
|
*
|
|
212
210
|
* @see https://mikro-orm.io/docs/defining-entities#lazy-scalar-properties
|
|
213
211
|
*/
|
|
214
|
-
lazy(
|
|
215
|
-
return
|
|
212
|
+
lazy() {
|
|
213
|
+
return this.assignOptions({ lazy: true });
|
|
216
214
|
}
|
|
217
215
|
/**
|
|
218
216
|
* Set true to define entity's unique primary key identifier.
|
|
219
217
|
*
|
|
220
218
|
* @see https://mikro-orm.io/docs/decorators#primarykey
|
|
221
219
|
*/
|
|
222
|
-
primary(
|
|
223
|
-
return
|
|
220
|
+
primary() {
|
|
221
|
+
return this.assignOptions({ primary: true });
|
|
224
222
|
}
|
|
225
223
|
/**
|
|
226
224
|
* Set true to define the properties as setter. (virtual)
|
|
@@ -234,7 +232,7 @@ export class PropertyOptionsBuilder {
|
|
|
234
232
|
* ```
|
|
235
233
|
*/
|
|
236
234
|
setter(setter = true) {
|
|
237
|
-
return
|
|
235
|
+
return this.assignOptions({ setter });
|
|
238
236
|
}
|
|
239
237
|
/**
|
|
240
238
|
* Set true to define the properties as getter. (virtual)
|
|
@@ -248,7 +246,7 @@ export class PropertyOptionsBuilder {
|
|
|
248
246
|
* ```
|
|
249
247
|
*/
|
|
250
248
|
getter(getter = true) {
|
|
251
|
-
return
|
|
249
|
+
return this.assignOptions({ getter });
|
|
252
250
|
}
|
|
253
251
|
/**
|
|
254
252
|
* When defining a property over a method (not a getter, a regular function), you can use this option to point
|
|
@@ -263,7 +261,7 @@ export class PropertyOptionsBuilder {
|
|
|
263
261
|
* ```
|
|
264
262
|
*/
|
|
265
263
|
getterName(getterName) {
|
|
266
|
-
return
|
|
264
|
+
return this.assignOptions({ getterName });
|
|
267
265
|
}
|
|
268
266
|
/**
|
|
269
267
|
* Set to define serialized primary key for MongoDB. (virtual)
|
|
@@ -272,7 +270,7 @@ export class PropertyOptionsBuilder {
|
|
|
272
270
|
* @see https://mikro-orm.io/docs/decorators#serializedprimarykey
|
|
273
271
|
*/
|
|
274
272
|
serializedPrimaryKey(serializedPrimaryKey = true) {
|
|
275
|
-
return
|
|
273
|
+
return this.assignOptions({ serializedPrimaryKey });
|
|
276
274
|
}
|
|
277
275
|
/**
|
|
278
276
|
* Set to use serialize property. Allow to specify a callback that will be used when serializing a property.
|
|
@@ -280,36 +278,36 @@ export class PropertyOptionsBuilder {
|
|
|
280
278
|
* @see https://mikro-orm.io/docs/serializing#property-serializers
|
|
281
279
|
*/
|
|
282
280
|
serializer(serializer) {
|
|
283
|
-
return
|
|
281
|
+
return this.assignOptions({ serializer });
|
|
284
282
|
}
|
|
285
283
|
/**
|
|
286
284
|
* Specify name of key for the serialized value.
|
|
287
285
|
*/
|
|
288
286
|
serializedName(serializedName) {
|
|
289
|
-
return
|
|
287
|
+
return this.assignOptions({ serializedName });
|
|
290
288
|
}
|
|
291
289
|
/**
|
|
292
290
|
* Specify serialization groups for `serialize()` calls. If a property does not specify any group, it will be included,
|
|
293
291
|
* otherwise only properties with a matching group are included.
|
|
294
292
|
*/
|
|
295
293
|
groups(...groups) {
|
|
296
|
-
return
|
|
294
|
+
return this.assignOptions({ groups });
|
|
297
295
|
}
|
|
298
296
|
/**
|
|
299
297
|
* Specify a custom order based on the values. (SQL only)
|
|
300
298
|
*/
|
|
301
299
|
customOrder(...customOrder) {
|
|
302
|
-
return
|
|
300
|
+
return this.assignOptions({ customOrder });
|
|
303
301
|
}
|
|
304
302
|
/**
|
|
305
303
|
* Specify comment of column for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}. (SQL only)
|
|
306
304
|
*/
|
|
307
305
|
comment(comment) {
|
|
308
|
-
return
|
|
306
|
+
return this.assignOptions({ comment });
|
|
309
307
|
}
|
|
310
308
|
/** mysql only */
|
|
311
309
|
extra(extra) {
|
|
312
|
-
return
|
|
310
|
+
return this.assignOptions({ extra });
|
|
313
311
|
}
|
|
314
312
|
/**
|
|
315
313
|
* Set to avoid a perpetual diff from the {@link https://mikro-orm.io/docs/schema-generator Schema Generator} when columns are generated.
|
|
@@ -317,342 +315,187 @@ export class PropertyOptionsBuilder {
|
|
|
317
315
|
* @see https://mikro-orm.io/docs/defining-entities#sql-generated-columns
|
|
318
316
|
*/
|
|
319
317
|
ignoreSchemaChanges(...ignoreSchemaChanges) {
|
|
320
|
-
return
|
|
318
|
+
return this.assignOptions({ ignoreSchemaChanges });
|
|
321
319
|
}
|
|
322
|
-
|
|
323
|
-
return
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
/** @internal */
|
|
327
|
-
export class EnumOptionsBuilder extends PropertyOptionsBuilder {
|
|
328
|
-
constructor(options) {
|
|
329
|
-
super(options);
|
|
330
|
-
this['~options'] = options;
|
|
331
|
-
}
|
|
332
|
-
array(array = true) {
|
|
333
|
-
return new EnumOptionsBuilder({ ...this['~options'], array });
|
|
320
|
+
array() {
|
|
321
|
+
return this.assignOptions({ array: true });
|
|
334
322
|
}
|
|
335
323
|
/** for postgres, by default it uses text column with check constraint */
|
|
336
324
|
nativeEnumName(nativeEnumName) {
|
|
337
|
-
return
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
/** @internal */
|
|
341
|
-
export class EmbeddedOptionsBuilder extends PropertyOptionsBuilder {
|
|
342
|
-
constructor(options) {
|
|
343
|
-
super(options);
|
|
344
|
-
this['~options'] = options;
|
|
325
|
+
return this.assignOptions({ nativeEnumName });
|
|
345
326
|
}
|
|
346
327
|
prefix(prefix) {
|
|
347
|
-
return
|
|
328
|
+
return this.assignOptions({ prefix });
|
|
348
329
|
}
|
|
349
330
|
prefixMode(prefixMode) {
|
|
350
|
-
return
|
|
331
|
+
return this.assignOptions({ prefixMode });
|
|
351
332
|
}
|
|
352
333
|
object(object = true) {
|
|
353
|
-
return
|
|
354
|
-
}
|
|
355
|
-
array(array = true) {
|
|
356
|
-
return new EmbeddedOptionsBuilder({ ...this['~options'], array });
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
/** @internal */
|
|
360
|
-
export class ReferenceOptionsBuilder extends PropertyOptionsBuilder {
|
|
361
|
-
constructor(options) {
|
|
362
|
-
super(options);
|
|
363
|
-
this['~options'] = options;
|
|
334
|
+
return this.assignOptions({ object });
|
|
364
335
|
}
|
|
365
336
|
/** Set what actions on owning entity should be cascaded to the relationship. Defaults to [Cascade.PERSIST, Cascade.MERGE] (see {@doclink cascading}). */
|
|
366
337
|
cascade(...cascade) {
|
|
367
|
-
return
|
|
338
|
+
return this.assignOptions({ cascade });
|
|
368
339
|
}
|
|
369
340
|
/** Always load the relationship. Discouraged for use with to-many relations for performance reasons. */
|
|
370
341
|
eager(eager = true) {
|
|
371
|
-
return
|
|
342
|
+
return this.assignOptions({ eager });
|
|
372
343
|
}
|
|
373
344
|
/** Override the default loading strategy for this property. This option has precedence over the global `loadStrategy`, but can be overridden by `FindOptions.strategy`. */
|
|
374
345
|
strategy(strategy) {
|
|
375
|
-
return
|
|
346
|
+
return this.assignOptions({ strategy });
|
|
376
347
|
}
|
|
377
|
-
/**
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
*/
|
|
381
|
-
/* v8 ignore next 3 */
|
|
382
|
-
ref(ref = true) {
|
|
383
|
-
return new ReferenceOptionsBuilder({ ...this['~options'], ref });
|
|
384
|
-
}
|
|
385
|
-
/**
|
|
386
|
-
* @internal
|
|
387
|
-
* re-declare to override type inference
|
|
388
|
-
*/
|
|
389
|
-
/* v8 ignore next 3 */
|
|
390
|
-
primary(primary = true) {
|
|
391
|
-
return new ReferenceOptionsBuilder({ ...this['~options'], primary });
|
|
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. */
|
|
349
|
+
owner() {
|
|
350
|
+
return this.assignOptions({ owner: true });
|
|
392
351
|
}
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
constructor(options) {
|
|
397
|
-
super(options);
|
|
398
|
-
this['~options'] = options;
|
|
352
|
+
/** For polymorphic relations. Specifies the property name that stores the entity type discriminator. Defaults to the property name. */
|
|
353
|
+
discriminator(discriminator) {
|
|
354
|
+
return this.assignOptions({ discriminator });
|
|
399
355
|
}
|
|
400
|
-
/**
|
|
401
|
-
|
|
402
|
-
return
|
|
356
|
+
/** For polymorphic relations. Custom mapping of discriminator values to entity class names. */
|
|
357
|
+
discriminatorMap(discriminatorMap) {
|
|
358
|
+
return this.assignOptions({ discriminatorMap });
|
|
403
359
|
}
|
|
404
360
|
/** Point to the inverse side property name. */
|
|
405
361
|
inversedBy(inversedBy) {
|
|
406
|
-
return
|
|
362
|
+
return this.assignOptions({ inversedBy });
|
|
407
363
|
}
|
|
408
364
|
/** Point to the owning side property name. */
|
|
409
365
|
mappedBy(mappedBy) {
|
|
410
|
-
return
|
|
366
|
+
return this.assignOptions({ mappedBy });
|
|
411
367
|
}
|
|
412
368
|
/** Condition for {@doclink collections#declarative-partial-loading | Declarative partial loading}. */
|
|
413
369
|
where(...where) {
|
|
414
|
-
return
|
|
370
|
+
return this.assignOptions({ where });
|
|
415
371
|
}
|
|
416
372
|
/** Set default ordering. */
|
|
417
373
|
orderBy(...orderBy) {
|
|
418
|
-
return
|
|
374
|
+
return this.assignOptions({ orderBy });
|
|
419
375
|
}
|
|
420
376
|
/** Force stable insertion order of items in the collection (see {@doclink collections | Collections}). */
|
|
421
377
|
fixedOrder(fixedOrder = true) {
|
|
422
|
-
return
|
|
378
|
+
return this.assignOptions({ fixedOrder });
|
|
423
379
|
}
|
|
424
380
|
/** Override default order column name (`id`) for fixed ordering. */
|
|
425
381
|
fixedOrderColumn(fixedOrderColumn) {
|
|
426
|
-
return
|
|
382
|
+
return this.assignOptions({ fixedOrderColumn });
|
|
427
383
|
}
|
|
428
384
|
/** Override default name for pivot table (see {@doclink naming-strategy | Naming Strategy}). */
|
|
429
385
|
pivotTable(pivotTable) {
|
|
430
|
-
return
|
|
386
|
+
return this.assignOptions({ pivotTable });
|
|
431
387
|
}
|
|
432
388
|
/** Set pivot entity for this relation (see {@doclink collections#custom-pivot-table-entity | Custom pivot table entity}). */
|
|
433
389
|
pivotEntity(pivotEntity) {
|
|
434
|
-
return
|
|
390
|
+
return this.assignOptions({ pivotEntity });
|
|
435
391
|
}
|
|
436
392
|
/** 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. */
|
|
437
393
|
joinColumn(joinColumn) {
|
|
438
|
-
return
|
|
394
|
+
return this.assignOptions({ joinColumn });
|
|
439
395
|
}
|
|
440
396
|
/** 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. */
|
|
441
397
|
joinColumns(...joinColumns) {
|
|
442
|
-
return
|
|
398
|
+
return this.assignOptions({ joinColumns });
|
|
443
399
|
}
|
|
444
400
|
/** 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. */
|
|
445
401
|
inverseJoinColumn(inverseJoinColumn) {
|
|
446
|
-
return
|
|
402
|
+
return this.assignOptions({ inverseJoinColumn });
|
|
447
403
|
}
|
|
448
404
|
/** 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. */
|
|
449
405
|
inverseJoinColumns(...inverseJoinColumns) {
|
|
450
|
-
return
|
|
406
|
+
return this.assignOptions({ inverseJoinColumns });
|
|
451
407
|
}
|
|
452
408
|
/** 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. */
|
|
453
409
|
referenceColumnName(referenceColumnName) {
|
|
454
|
-
return
|
|
410
|
+
return this.assignOptions({ referenceColumnName });
|
|
455
411
|
}
|
|
456
412
|
/** 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. */
|
|
457
413
|
referencedColumnNames(...referencedColumnNames) {
|
|
458
|
-
return
|
|
414
|
+
return this.assignOptions({ referencedColumnNames });
|
|
415
|
+
}
|
|
416
|
+
/** Specify the property name on the target entity that this FK references instead of the primary key. */
|
|
417
|
+
targetKey(targetKey) {
|
|
418
|
+
return this.assignOptions({ targetKey });
|
|
459
419
|
}
|
|
460
420
|
/** What to do when the target entity gets deleted. */
|
|
461
421
|
deleteRule(deleteRule) {
|
|
462
|
-
return
|
|
422
|
+
return this.assignOptions({ deleteRule });
|
|
463
423
|
}
|
|
464
424
|
/** What to do when the reference to the target entity gets updated. */
|
|
465
425
|
updateRule(updateRule) {
|
|
466
|
-
return
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
/** @internal */
|
|
470
|
-
export class ManyToOneOptionsBuilder extends ReferenceOptionsBuilder {
|
|
471
|
-
constructor(options) {
|
|
472
|
-
super(options);
|
|
473
|
-
this['~options'] = options;
|
|
474
|
-
}
|
|
475
|
-
/** Point to the inverse side property name. */
|
|
476
|
-
inversedBy(inversedBy) {
|
|
477
|
-
return new ManyToOneOptionsBuilder({ ...this['~options'], inversedBy });
|
|
478
|
-
}
|
|
479
|
-
/** Wrap the entity in {@apilink Reference} wrapper. */
|
|
480
|
-
ref(ref = true) {
|
|
481
|
-
return new ManyToOneOptionsBuilder({ ...this['~options'], ref });
|
|
482
|
-
}
|
|
483
|
-
/** Use this relation as a primary key. */
|
|
484
|
-
primary(primary = true) {
|
|
485
|
-
return new ManyToOneOptionsBuilder({ ...this['~options'], primary });
|
|
426
|
+
return this.assignOptions({ updateRule });
|
|
486
427
|
}
|
|
487
428
|
/** Map this relation to the primary key value instead of an entity. */
|
|
488
|
-
mapToPk(
|
|
489
|
-
return
|
|
490
|
-
}
|
|
491
|
-
/** 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. */
|
|
492
|
-
joinColumn(joinColumn) {
|
|
493
|
-
return new ManyToOneOptionsBuilder({ ...this['~options'], joinColumn });
|
|
429
|
+
mapToPk() {
|
|
430
|
+
return this.assignOptions({ mapToPk: true });
|
|
494
431
|
}
|
|
495
|
-
/**
|
|
496
|
-
|
|
497
|
-
return
|
|
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. */
|
|
433
|
+
deferMode(deferMode) {
|
|
434
|
+
return this.assignOptions({ deferMode });
|
|
498
435
|
}
|
|
499
436
|
/** 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. */
|
|
500
437
|
ownColumns(...ownColumns) {
|
|
501
|
-
return
|
|
438
|
+
return this.assignOptions({ ownColumns });
|
|
502
439
|
}
|
|
503
|
-
/**
|
|
504
|
-
|
|
505
|
-
return
|
|
440
|
+
/** Enable/disable foreign key constraint creation on this relation */
|
|
441
|
+
createForeignKeyConstraint(createForeignKeyConstraint = true) {
|
|
442
|
+
return this.assignOptions({ createForeignKeyConstraint });
|
|
506
443
|
}
|
|
507
|
-
/**
|
|
508
|
-
|
|
509
|
-
return
|
|
510
|
-
}
|
|
511
|
-
/** What to do when the target entity gets deleted. */
|
|
512
|
-
deleteRule(deleteRule) {
|
|
513
|
-
return new ManyToOneOptionsBuilder({ ...this['~options'], deleteRule });
|
|
514
|
-
}
|
|
515
|
-
/** What to do when the reference to the target entity gets updated. */
|
|
516
|
-
updateRule(updateRule) {
|
|
517
|
-
return new ManyToOneOptionsBuilder({ ...this['~options'], updateRule });
|
|
518
|
-
}
|
|
519
|
-
/** 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. */
|
|
520
|
-
deferMode(deferMode) {
|
|
521
|
-
return new ManyToOneOptionsBuilder({ ...this['~options'], deferMode });
|
|
522
|
-
}
|
|
523
|
-
}
|
|
524
|
-
/** @internal */
|
|
525
|
-
export class OneToManyOptionsBuilder extends ReferenceOptionsBuilder {
|
|
526
|
-
constructor(options) {
|
|
527
|
-
super(options);
|
|
528
|
-
this['~options'] = options;
|
|
444
|
+
/** Set a custom foreign key constraint name, overriding NamingStrategy.indexName(). */
|
|
445
|
+
foreignKeyName(foreignKeyName) {
|
|
446
|
+
return this.assignOptions({ foreignKeyName });
|
|
529
447
|
}
|
|
530
448
|
/** Remove the entity when it gets disconnected from the relationship (see {@doclink cascading | Cascading}). */
|
|
531
449
|
orphanRemoval(orphanRemoval = true) {
|
|
532
|
-
return
|
|
533
|
-
}
|
|
534
|
-
/** Set default ordering. */
|
|
535
|
-
orderBy(orderBy) {
|
|
536
|
-
return new OneToManyOptionsBuilder({ ...this['~options'], orderBy });
|
|
537
|
-
}
|
|
538
|
-
/** Condition for {@doclink collections#declarative-partial-loading | Declarative partial loading}. */
|
|
539
|
-
where(where) {
|
|
540
|
-
return new OneToManyOptionsBuilder({ ...this['~options'], where });
|
|
541
|
-
}
|
|
542
|
-
/** 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. */
|
|
543
|
-
joinColumn(joinColumn) {
|
|
544
|
-
return new OneToManyOptionsBuilder({ ...this['~options'], joinColumn });
|
|
545
|
-
}
|
|
546
|
-
/** 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. */
|
|
547
|
-
joinColumns(...joinColumns) {
|
|
548
|
-
return new OneToManyOptionsBuilder({ ...this['~options'], joinColumns });
|
|
549
|
-
}
|
|
550
|
-
/** 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. */
|
|
551
|
-
inverseJoinColumn(inverseJoinColumn) {
|
|
552
|
-
return new OneToManyOptionsBuilder({ ...this['~options'], inverseJoinColumn });
|
|
553
|
-
}
|
|
554
|
-
/** 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. */
|
|
555
|
-
inverseJoinColumns(...inverseJoinColumns) {
|
|
556
|
-
return new OneToManyOptionsBuilder({ ...this['~options'], inverseJoinColumns });
|
|
557
|
-
}
|
|
558
|
-
/** 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. */
|
|
559
|
-
referenceColumnName(referenceColumnName) {
|
|
560
|
-
return new OneToManyOptionsBuilder({ ...this['~options'], referenceColumnName });
|
|
450
|
+
return this.assignOptions({ orphanRemoval });
|
|
561
451
|
}
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
return new OneToManyOptionsBuilder({ ...this['~options'], referencedColumnNames });
|
|
452
|
+
accessor(accessor = true) {
|
|
453
|
+
return this.assignOptions({ accessor });
|
|
565
454
|
}
|
|
566
455
|
}
|
|
567
456
|
/** @internal */
|
|
568
|
-
export class OneToManyOptionsBuilderOnlyMappedBy {
|
|
569
|
-
constructor(options) {
|
|
570
|
-
this['~options'] = options;
|
|
571
|
-
}
|
|
457
|
+
export class OneToManyOptionsBuilderOnlyMappedBy extends UniversalPropertyOptionsBuilder {
|
|
572
458
|
/** Point to the owning side property name. */
|
|
573
459
|
mappedBy(mappedBy) {
|
|
574
|
-
return new
|
|
575
|
-
}
|
|
576
|
-
}
|
|
577
|
-
/** @internal */
|
|
578
|
-
export class OneToOneOptionsBuilder extends ReferenceOptionsBuilder {
|
|
579
|
-
constructor(options) {
|
|
580
|
-
super(options);
|
|
581
|
-
this['~options'] = options;
|
|
582
|
-
}
|
|
583
|
-
/** 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. */
|
|
584
|
-
owner(owner = true) {
|
|
585
|
-
return new OneToOneOptionsBuilder({ ...this['~options'], owner });
|
|
586
|
-
}
|
|
587
|
-
/** Point to the inverse side property name. */
|
|
588
|
-
inversedBy(inversedBy) {
|
|
589
|
-
return new OneToOneOptionsBuilder({ ...this['~options'], inversedBy });
|
|
590
|
-
}
|
|
591
|
-
/** Wrap the entity in {@apilink Reference} wrapper. */
|
|
592
|
-
ref(ref = true) {
|
|
593
|
-
return new OneToOneOptionsBuilder({ ...this['~options'], ref });
|
|
594
|
-
}
|
|
595
|
-
/** Use this relation as a primary key. */
|
|
596
|
-
primary(primary = true) {
|
|
597
|
-
return new OneToOneOptionsBuilder({ ...this['~options'], primary });
|
|
598
|
-
}
|
|
599
|
-
/** Map this relation to the primary key value instead of an entity. */
|
|
600
|
-
mapToPk(mapToPk = true) {
|
|
601
|
-
return new OneToOneOptionsBuilder({ ...this['~options'], mapToPk });
|
|
602
|
-
}
|
|
603
|
-
/** 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. */
|
|
604
|
-
ownColumns(...ownColumns) {
|
|
605
|
-
return new OneToOneOptionsBuilder({ ...this['~options'], ownColumns });
|
|
606
|
-
}
|
|
607
|
-
/** What to do when the target entity gets deleted. */
|
|
608
|
-
deleteRule(deleteRule) {
|
|
609
|
-
return new OneToOneOptionsBuilder({ ...this['~options'], deleteRule });
|
|
610
|
-
}
|
|
611
|
-
/** What to do when the reference to the target entity gets updated. */
|
|
612
|
-
updateRule(updateRule) {
|
|
613
|
-
return new OneToOneOptionsBuilder({ ...this['~options'], updateRule });
|
|
614
|
-
}
|
|
615
|
-
/** 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. */
|
|
616
|
-
deferMode(deferMode) {
|
|
617
|
-
return new OneToOneOptionsBuilder({ ...this['~options'], deferMode });
|
|
460
|
+
return new UniversalPropertyOptionsBuilder({ ...this['~options'], mappedBy });
|
|
618
461
|
}
|
|
619
462
|
}
|
|
620
463
|
function createPropertyBuilders(options) {
|
|
621
|
-
return Object.fromEntries(Object.entries(options).map(([key, value]) => [key, () => new
|
|
464
|
+
return Object.fromEntries(Object.entries(options).map(([key, value]) => [key, () => new UniversalPropertyOptionsBuilder({ type: value })]));
|
|
622
465
|
}
|
|
623
466
|
const propertyBuilders = {
|
|
624
467
|
...createPropertyBuilders(types),
|
|
625
|
-
bigint: (mode) => new
|
|
626
|
-
array: (toJsValue = i => i, toDbValue = i => i) => new
|
|
627
|
-
decimal: (mode) => new
|
|
628
|
-
json: () => new
|
|
629
|
-
formula: (formula) => new
|
|
630
|
-
|
|
631
|
-
|
|
468
|
+
bigint: (mode) => new UniversalPropertyOptionsBuilder({ type: new types.bigint(mode) }),
|
|
469
|
+
array: (toJsValue = i => i, toDbValue = i => i) => new UniversalPropertyOptionsBuilder({ type: new types.array(toJsValue, toDbValue) }),
|
|
470
|
+
decimal: (mode) => new UniversalPropertyOptionsBuilder({ type: new types.decimal(mode) }),
|
|
471
|
+
json: () => new UniversalPropertyOptionsBuilder({ type: types.json }),
|
|
472
|
+
formula: (formula) => new UniversalPropertyOptionsBuilder({ formula }),
|
|
473
|
+
datetime: (length) => new UniversalPropertyOptionsBuilder({ type: types.datetime, length }),
|
|
474
|
+
time: (length) => new UniversalPropertyOptionsBuilder({ type: types.time, length }),
|
|
475
|
+
type: (type) => new UniversalPropertyOptionsBuilder({ type }),
|
|
476
|
+
enum: (items) => new UniversalPropertyOptionsBuilder({
|
|
632
477
|
enum: true,
|
|
633
478
|
items,
|
|
634
479
|
}),
|
|
635
|
-
embedded: (target) => new
|
|
480
|
+
embedded: (target) => new UniversalPropertyOptionsBuilder({
|
|
636
481
|
entity: () => target,
|
|
637
482
|
kind: 'embedded',
|
|
638
483
|
}),
|
|
639
|
-
manyToMany: (target) => new
|
|
484
|
+
manyToMany: (target) => new UniversalPropertyOptionsBuilder({
|
|
640
485
|
entity: () => target,
|
|
641
486
|
kind: 'm:n',
|
|
642
487
|
}),
|
|
643
|
-
manyToOne: (target) => new
|
|
488
|
+
manyToOne: (target) => new UniversalPropertyOptionsBuilder({
|
|
644
489
|
entity: () => target,
|
|
645
490
|
kind: 'm:1',
|
|
646
|
-
ref: true,
|
|
647
491
|
}),
|
|
648
492
|
oneToMany: (target) => new OneToManyOptionsBuilderOnlyMappedBy({
|
|
649
493
|
entity: () => target,
|
|
650
494
|
kind: '1:m',
|
|
651
495
|
}),
|
|
652
|
-
oneToOne: (target) => new
|
|
496
|
+
oneToOne: (target) => new UniversalPropertyOptionsBuilder({
|
|
653
497
|
entity: () => target,
|
|
654
498
|
kind: '1:1',
|
|
655
|
-
ref: true,
|
|
656
499
|
}),
|
|
657
500
|
};
|
|
658
501
|
function getBuilderOptions(builder) {
|
|
@@ -662,8 +505,8 @@ export function defineEntity(meta) {
|
|
|
662
505
|
const { properties: propertiesOrGetter, ...options } = meta;
|
|
663
506
|
const propertyOptions = typeof propertiesOrGetter === 'function' ? propertiesOrGetter(propertyBuilders) : propertiesOrGetter;
|
|
664
507
|
const properties = {};
|
|
508
|
+
const values = new Map();
|
|
665
509
|
for (const [key, builder] of Object.entries(propertyOptions)) {
|
|
666
|
-
const values = new Map();
|
|
667
510
|
if (typeof builder === 'function') {
|
|
668
511
|
Object.defineProperty(properties, key, {
|
|
669
512
|
get: () => {
|
|
@@ -691,3 +534,4 @@ export function defineEntity(meta) {
|
|
|
691
534
|
return new EntitySchema({ properties, ...options });
|
|
692
535
|
}
|
|
693
536
|
defineEntity.properties = propertyBuilders;
|
|
537
|
+
export { propertyBuilders as p };
|