@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.
Files changed (209) hide show
  1. package/EntityManager.d.ts +91 -59
  2. package/EntityManager.js +303 -251
  3. package/MikroORM.d.ts +44 -35
  4. package/MikroORM.js +109 -143
  5. package/README.md +2 -0
  6. package/cache/FileCacheAdapter.d.ts +1 -1
  7. package/cache/FileCacheAdapter.js +17 -8
  8. package/cache/GeneratedCacheAdapter.d.ts +0 -1
  9. package/cache/GeneratedCacheAdapter.js +0 -2
  10. package/cache/index.d.ts +0 -1
  11. package/cache/index.js +0 -1
  12. package/connections/Connection.d.ts +12 -5
  13. package/connections/Connection.js +21 -12
  14. package/drivers/DatabaseDriver.d.ts +25 -16
  15. package/drivers/DatabaseDriver.js +118 -35
  16. package/drivers/IDatabaseDriver.d.ts +42 -19
  17. package/entity/BaseEntity.d.ts +61 -2
  18. package/entity/BaseEntity.js +0 -3
  19. package/entity/Collection.d.ts +101 -29
  20. package/entity/Collection.js +436 -104
  21. package/entity/EntityAssigner.d.ts +1 -1
  22. package/entity/EntityAssigner.js +26 -18
  23. package/entity/EntityFactory.d.ts +7 -1
  24. package/entity/EntityFactory.js +83 -54
  25. package/entity/EntityHelper.d.ts +2 -2
  26. package/entity/EntityHelper.js +48 -15
  27. package/entity/EntityLoader.d.ts +7 -6
  28. package/entity/EntityLoader.js +221 -93
  29. package/entity/EntityRepository.d.ts +27 -7
  30. package/entity/EntityRepository.js +8 -2
  31. package/entity/PolymorphicRef.d.ts +12 -0
  32. package/entity/PolymorphicRef.js +18 -0
  33. package/entity/Reference.d.ts +1 -5
  34. package/entity/Reference.js +21 -12
  35. package/entity/WrappedEntity.d.ts +0 -5
  36. package/entity/WrappedEntity.js +2 -7
  37. package/entity/defineEntity.d.ts +380 -310
  38. package/entity/defineEntity.js +124 -273
  39. package/entity/index.d.ts +2 -2
  40. package/entity/index.js +2 -2
  41. package/entity/utils.js +1 -1
  42. package/entity/validators.d.ts +11 -0
  43. package/entity/validators.js +65 -0
  44. package/enums.d.ts +8 -6
  45. package/enums.js +2 -1
  46. package/errors.d.ts +20 -10
  47. package/errors.js +55 -23
  48. package/events/EventManager.d.ts +2 -1
  49. package/events/EventManager.js +19 -11
  50. package/hydration/Hydrator.js +1 -2
  51. package/hydration/ObjectHydrator.d.ts +4 -4
  52. package/hydration/ObjectHydrator.js +87 -35
  53. package/index.d.ts +2 -2
  54. package/index.js +1 -2
  55. package/logging/DefaultLogger.d.ts +1 -1
  56. package/logging/DefaultLogger.js +1 -0
  57. package/logging/SimpleLogger.d.ts +1 -1
  58. package/logging/colors.d.ts +1 -1
  59. package/logging/colors.js +7 -6
  60. package/logging/index.d.ts +1 -0
  61. package/logging/index.js +1 -0
  62. package/logging/inspect.d.ts +2 -0
  63. package/logging/inspect.js +11 -0
  64. package/metadata/EntitySchema.d.ts +47 -23
  65. package/metadata/EntitySchema.js +92 -33
  66. package/metadata/MetadataDiscovery.d.ts +64 -9
  67. package/metadata/MetadataDiscovery.js +778 -325
  68. package/metadata/MetadataProvider.d.ts +11 -2
  69. package/metadata/MetadataProvider.js +46 -2
  70. package/metadata/MetadataStorage.d.ts +13 -11
  71. package/metadata/MetadataStorage.js +70 -37
  72. package/metadata/MetadataValidator.d.ts +32 -9
  73. package/metadata/MetadataValidator.js +196 -41
  74. package/metadata/discover-entities.d.ts +5 -0
  75. package/metadata/discover-entities.js +40 -0
  76. package/metadata/index.d.ts +1 -1
  77. package/metadata/index.js +1 -1
  78. package/metadata/types.d.ts +526 -0
  79. package/metadata/types.js +1 -0
  80. package/naming-strategy/AbstractNamingStrategy.d.ts +16 -4
  81. package/naming-strategy/AbstractNamingStrategy.js +20 -2
  82. package/naming-strategy/EntityCaseNamingStrategy.d.ts +3 -3
  83. package/naming-strategy/EntityCaseNamingStrategy.js +6 -5
  84. package/naming-strategy/MongoNamingStrategy.d.ts +3 -3
  85. package/naming-strategy/MongoNamingStrategy.js +6 -6
  86. package/naming-strategy/NamingStrategy.d.ts +28 -4
  87. package/naming-strategy/UnderscoreNamingStrategy.d.ts +3 -3
  88. package/naming-strategy/UnderscoreNamingStrategy.js +6 -6
  89. package/not-supported.d.ts +2 -0
  90. package/not-supported.js +4 -0
  91. package/package.json +19 -11
  92. package/platforms/ExceptionConverter.js +1 -1
  93. package/platforms/Platform.d.ts +7 -14
  94. package/platforms/Platform.js +20 -43
  95. package/serialization/EntitySerializer.d.ts +5 -0
  96. package/serialization/EntitySerializer.js +47 -27
  97. package/serialization/EntityTransformer.js +28 -18
  98. package/serialization/SerializationContext.d.ts +6 -6
  99. package/serialization/SerializationContext.js +3 -3
  100. package/types/ArrayType.d.ts +1 -1
  101. package/types/ArrayType.js +2 -3
  102. package/types/BigIntType.d.ts +8 -6
  103. package/types/BigIntType.js +1 -1
  104. package/types/BlobType.d.ts +0 -1
  105. package/types/BlobType.js +0 -3
  106. package/types/BooleanType.d.ts +1 -0
  107. package/types/BooleanType.js +3 -0
  108. package/types/DecimalType.d.ts +6 -4
  109. package/types/DecimalType.js +2 -2
  110. package/types/DoubleType.js +1 -1
  111. package/types/EnumArrayType.js +1 -2
  112. package/types/JsonType.d.ts +1 -1
  113. package/types/JsonType.js +7 -2
  114. package/types/TinyIntType.js +1 -1
  115. package/types/Type.d.ts +2 -4
  116. package/types/Type.js +3 -3
  117. package/types/Uint8ArrayType.d.ts +0 -1
  118. package/types/Uint8ArrayType.js +1 -4
  119. package/types/index.d.ts +1 -1
  120. package/typings.d.ts +381 -171
  121. package/typings.js +97 -44
  122. package/unit-of-work/ChangeSet.d.ts +4 -6
  123. package/unit-of-work/ChangeSet.js +4 -5
  124. package/unit-of-work/ChangeSetComputer.d.ts +1 -3
  125. package/unit-of-work/ChangeSetComputer.js +35 -14
  126. package/unit-of-work/ChangeSetPersister.d.ts +7 -3
  127. package/unit-of-work/ChangeSetPersister.js +83 -25
  128. package/unit-of-work/CommitOrderCalculator.d.ts +12 -10
  129. package/unit-of-work/CommitOrderCalculator.js +13 -13
  130. package/unit-of-work/IdentityMap.d.ts +12 -0
  131. package/unit-of-work/IdentityMap.js +39 -1
  132. package/unit-of-work/UnitOfWork.d.ts +27 -3
  133. package/unit-of-work/UnitOfWork.js +258 -92
  134. package/utils/AbstractSchemaGenerator.d.ts +5 -5
  135. package/utils/AbstractSchemaGenerator.js +28 -17
  136. package/utils/AsyncContext.d.ts +6 -0
  137. package/utils/AsyncContext.js +42 -0
  138. package/utils/Configuration.d.ts +795 -209
  139. package/utils/Configuration.js +150 -192
  140. package/utils/ConfigurationLoader.d.ts +1 -54
  141. package/utils/ConfigurationLoader.js +1 -352
  142. package/utils/Cursor.d.ts +0 -3
  143. package/utils/Cursor.js +24 -11
  144. package/utils/DataloaderUtils.d.ts +10 -5
  145. package/utils/DataloaderUtils.js +29 -12
  146. package/utils/EntityComparator.d.ts +16 -9
  147. package/utils/EntityComparator.js +158 -58
  148. package/utils/QueryHelper.d.ts +18 -6
  149. package/utils/QueryHelper.js +76 -23
  150. package/utils/RawQueryFragment.d.ts +28 -34
  151. package/utils/RawQueryFragment.js +35 -71
  152. package/utils/RequestContext.js +2 -2
  153. package/utils/TransactionContext.js +2 -2
  154. package/utils/TransactionManager.js +28 -4
  155. package/utils/Utils.d.ts +14 -127
  156. package/utils/Utils.js +85 -397
  157. package/utils/clone.js +8 -23
  158. package/utils/env-vars.d.ts +7 -0
  159. package/utils/env-vars.js +97 -0
  160. package/utils/fs-utils.d.ts +33 -0
  161. package/utils/fs-utils.js +192 -0
  162. package/utils/index.d.ts +1 -1
  163. package/utils/index.js +1 -1
  164. package/utils/upsert-utils.d.ts +9 -4
  165. package/utils/upsert-utils.js +46 -3
  166. package/decorators/Check.d.ts +0 -3
  167. package/decorators/Check.js +0 -13
  168. package/decorators/CreateRequestContext.d.ts +0 -3
  169. package/decorators/CreateRequestContext.js +0 -32
  170. package/decorators/Embeddable.d.ts +0 -8
  171. package/decorators/Embeddable.js +0 -11
  172. package/decorators/Embedded.d.ts +0 -12
  173. package/decorators/Embedded.js +0 -18
  174. package/decorators/Entity.d.ts +0 -33
  175. package/decorators/Entity.js +0 -12
  176. package/decorators/Enum.d.ts +0 -9
  177. package/decorators/Enum.js +0 -16
  178. package/decorators/Filter.d.ts +0 -2
  179. package/decorators/Filter.js +0 -8
  180. package/decorators/Formula.d.ts +0 -4
  181. package/decorators/Formula.js +0 -15
  182. package/decorators/Indexed.d.ts +0 -19
  183. package/decorators/Indexed.js +0 -20
  184. package/decorators/ManyToMany.d.ts +0 -42
  185. package/decorators/ManyToMany.js +0 -14
  186. package/decorators/ManyToOne.d.ts +0 -34
  187. package/decorators/ManyToOne.js +0 -14
  188. package/decorators/OneToMany.d.ts +0 -28
  189. package/decorators/OneToMany.js +0 -17
  190. package/decorators/OneToOne.d.ts +0 -28
  191. package/decorators/OneToOne.js +0 -7
  192. package/decorators/PrimaryKey.d.ts +0 -8
  193. package/decorators/PrimaryKey.js +0 -20
  194. package/decorators/Property.d.ts +0 -250
  195. package/decorators/Property.js +0 -32
  196. package/decorators/Transactional.d.ts +0 -14
  197. package/decorators/Transactional.js +0 -28
  198. package/decorators/hooks.d.ts +0 -16
  199. package/decorators/hooks.js +0 -47
  200. package/decorators/index.d.ts +0 -17
  201. package/decorators/index.js +0 -17
  202. package/entity/ArrayCollection.d.ts +0 -118
  203. package/entity/ArrayCollection.js +0 -407
  204. package/entity/EntityValidator.d.ts +0 -19
  205. package/entity/EntityValidator.js +0 -150
  206. package/metadata/ReflectMetadataProvider.d.ts +0 -8
  207. package/metadata/ReflectMetadataProvider.js +0 -44
  208. package/utils/resolveContextProvider.d.ts +0 -10
  209. package/utils/resolveContextProvider.js +0 -28
@@ -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 PropertyOptionsBuilder {
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 new PropertyOptionsBuilder({ ...this['~options'], name });
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 new PropertyOptionsBuilder({ ...this['~options'], fieldName });
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 new PropertyOptionsBuilder({ ...this['~options'], fieldNames });
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 new PropertyOptionsBuilder({ ...this['~options'], columnType });
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 new PropertyOptionsBuilder({ ...this['~options'], columnTypes });
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 new PropertyOptionsBuilder({ ...this['~options'], type });
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 new PropertyOptionsBuilder({ ...this['~options'], runtimeType });
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 new PropertyOptionsBuilder({ ...this['~options'], length });
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 new PropertyOptionsBuilder({ ...this['~options'], precision });
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 new PropertyOptionsBuilder({ ...this['~options'], scale });
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 new PropertyOptionsBuilder({ ...this['~options'], autoincrement });
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 new PropertyOptionsBuilder({ ...this['~options'], returning });
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 new PropertyOptionsBuilder({ ...this['~options'], onCreate });
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 new PropertyOptionsBuilder({ ...this['~options'], onUpdate });
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 new PropertyOptionsBuilder({ ...this['~options'], default: defaultValue });
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 new PropertyOptionsBuilder({ ...this['~options'], defaultRaw });
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 new PropertyOptionsBuilder({ ...this['~options'], formula });
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 new PropertyOptionsBuilder({ ...this['~options'], generated });
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 new PropertyOptionsBuilder({ ...this['~options'], nullable });
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 new PropertyOptionsBuilder({ ...this['~options'], unsigned });
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 new PropertyOptionsBuilder({ ...this['~options'], persist });
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 new PropertyOptionsBuilder({ ...this['~options'], hydrate });
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 new PropertyOptionsBuilder({ ...this['~options'], ref });
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 new PropertyOptionsBuilder({ ...this['~options'], hidden });
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 new PropertyOptionsBuilder({ ...this['~options'], version });
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 new PropertyOptionsBuilder({ ...this['~options'], concurrencyCheck });
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 new PropertyOptionsBuilder({ ...this['~options'], index });
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 new PropertyOptionsBuilder({ ...this['~options'], unique });
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 new PropertyOptionsBuilder({ ...this['~options'], check });
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 new PropertyOptionsBuilder({ ...this['~options'], lazy, ref });
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 new PropertyOptionsBuilder({ ...this['~options'], primary });
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 new PropertyOptionsBuilder({ ...this['~options'], setter });
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 new PropertyOptionsBuilder({ ...this['~options'], getter });
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 new PropertyOptionsBuilder({ ...this['~options'], getterName });
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 new PropertyOptionsBuilder({ ...this['~options'], serializedPrimaryKey });
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 new PropertyOptionsBuilder({ ...this['~options'], serializer });
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 new PropertyOptionsBuilder({ ...this['~options'], serializedName });
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 new PropertyOptionsBuilder({ ...this['~options'], groups });
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 new PropertyOptionsBuilder({ ...this['~options'], customOrder });
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 new PropertyOptionsBuilder({ ...this['~options'], comment });
310
+ return this.assignOptions({ comment });
309
311
  }
310
312
  /** mysql only */
311
313
  extra(extra) {
312
- return new PropertyOptionsBuilder({ ...this['~options'], extra });
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 new PropertyOptionsBuilder({ ...this['~options'], ignoreSchemaChanges });
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 new EnumOptionsBuilder({ ...this['~options'], array });
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 new EnumOptionsBuilder({ ...this['~options'], nativeEnumName });
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 new EmbeddedOptionsBuilder({ ...this['~options'], prefix });
332
+ return this.assignOptions({ prefix });
348
333
  }
349
334
  prefixMode(prefixMode) {
350
- return new EmbeddedOptionsBuilder({ ...this['~options'], prefixMode });
335
+ return this.assignOptions({ prefixMode });
351
336
  }
352
337
  object(object = true) {
353
- return new EmbeddedOptionsBuilder({ ...this['~options'], object });
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 new ReferenceOptionsBuilder({ ...this['~options'], cascade });
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 new ReferenceOptionsBuilder({ ...this['~options'], eager });
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 new ReferenceOptionsBuilder({ ...this['~options'], strategy });
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 new ManyToManyOptionsBuilder({ ...this['~options'], owner });
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 new ManyToManyOptionsBuilder({ ...this['~options'], inversedBy });
366
+ return this.assignOptions({ inversedBy });
407
367
  }
408
368
  /** Point to the owning side property name. */
409
369
  mappedBy(mappedBy) {
410
- return new ManyToManyOptionsBuilder({ ...this['~options'], mappedBy });
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 new ManyToManyOptionsBuilder({ ...this['~options'], where: where });
374
+ return this.assignOptions({ where });
415
375
  }
416
376
  /** Set default ordering. */
417
377
  orderBy(...orderBy) {
418
- return new ManyToManyOptionsBuilder({ ...this['~options'], orderBy });
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 new ManyToManyOptionsBuilder({ ...this['~options'], fixedOrder });
382
+ return this.assignOptions({ fixedOrder });
423
383
  }
424
384
  /** Override default order column name (`id`) for fixed ordering. */
425
385
  fixedOrderColumn(fixedOrderColumn) {
426
- return new ManyToManyOptionsBuilder({ ...this['~options'], fixedOrderColumn });
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 new ManyToManyOptionsBuilder({ ...this['~options'], pivotTable });
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 new ManyToManyOptionsBuilder({ ...this['~options'], pivotEntity });
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 new ManyToManyOptionsBuilder({ ...this['~options'], joinColumn });
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 new ManyToManyOptionsBuilder({ ...this['~options'], joinColumns });
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 new ManyToManyOptionsBuilder({ ...this['~options'], inverseJoinColumn });
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 new ManyToManyOptionsBuilder({ ...this['~options'], inverseJoinColumns });
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 new ManyToManyOptionsBuilder({ ...this['~options'], referenceColumnName });
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 new ManyToManyOptionsBuilder({ ...this['~options'], referencedColumnNames });
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 new ManyToManyOptionsBuilder({ ...this['~options'], deleteRule });
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 new ManyToManyOptionsBuilder({ ...this['~options'], updateRule });
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 new ManyToOneOptionsBuilder({ ...this['~options'], mapToPk });
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
- /** 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. */
496
- joinColumns(...joinColumns) {
497
- return new ManyToOneOptionsBuilder({ ...this['~options'], joinColumns });
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 new ManyToOneOptionsBuilder({ ...this['~options'], ownColumns });
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
- /** What to do when the target entity gets deleted. */
512
- deleteRule(deleteRule) {
513
- return new ManyToOneOptionsBuilder({ ...this['~options'], deleteRule });
444
+ /** Enable/disable foreign key constraint creation on this relation */
445
+ createForeignKeyConstraint(createForeignKeyConstraint = true) {
446
+ return this.assignOptions({ createForeignKeyConstraint });
514
447
  }
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;
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 new OneToManyOptionsBuilder({ ...this['~options'], orphanRemoval });
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
- /** 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 });
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 OneToManyOptionsBuilder({ ...this['~options'], mappedBy });
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 PropertyOptionsBuilder({ type: value })]));
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
- json: () => new PropertyOptionsBuilder({ type: types.json }),
626
- formula: (formula) => new PropertyOptionsBuilder({ formula }),
627
- type: (type) => new PropertyOptionsBuilder({ type }),
628
- enum: (items) => new EnumOptionsBuilder({
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 EmbeddedOptionsBuilder({
484
+ embedded: (target) => new UniversalPropertyOptionsBuilder({
633
485
  entity: () => target,
634
486
  kind: 'embedded',
635
487
  }),
636
- manyToMany: (target) => new ManyToManyOptionsBuilder({
488
+ manyToMany: (target) => new UniversalPropertyOptionsBuilder({
637
489
  entity: () => target,
638
490
  kind: 'm:n',
639
491
  }),
640
- manyToOne: (target) => new ManyToOneOptionsBuilder({
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 OneToOneOptionsBuilder({
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 };