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