@mikro-orm/core 6.5.8-dev.0 → 6.5.8-dev.10

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.
@@ -11,11 +11,14 @@ class PropertyOptionsBuilder {
11
11
  constructor(options) {
12
12
  this['~options'] = options;
13
13
  }
14
+ assignOptions(options) {
15
+ return new PropertyOptionsBuilder({ ...this['~options'], ...options });
16
+ }
14
17
  /**
15
18
  * Alias for `fieldName`.
16
19
  */
17
20
  name(name) {
18
- return new PropertyOptionsBuilder({ ...this['~options'], name });
21
+ return this.assignOptions({ name });
19
22
  }
20
23
  /**
21
24
  * Specify database column name for this property.
@@ -23,7 +26,7 @@ class PropertyOptionsBuilder {
23
26
  * @see https://mikro-orm.io/docs/naming-strategy
24
27
  */
25
28
  fieldName(fieldName) {
26
- return new PropertyOptionsBuilder({ ...this['~options'], fieldName });
29
+ return this.assignOptions({ fieldName });
27
30
  }
28
31
  /**
29
32
  * Specify database column names for this property.
@@ -32,19 +35,19 @@ class PropertyOptionsBuilder {
32
35
  * @see https://mikro-orm.io/docs/naming-strategy
33
36
  */
34
37
  fieldNames(...fieldNames) {
35
- return new PropertyOptionsBuilder({ ...this['~options'], fieldNames });
38
+ return this.assignOptions({ fieldNames });
36
39
  }
37
40
  /**
38
41
  * 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)
39
42
  */
40
43
  columnType(columnType) {
41
- return new PropertyOptionsBuilder({ ...this['~options'], columnType });
44
+ return this.assignOptions({ columnType });
42
45
  }
43
46
  /**
44
47
  * 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)
45
48
  */
46
49
  columnTypes(...columnTypes) {
47
- return new PropertyOptionsBuilder({ ...this['~options'], columnTypes });
50
+ return this.assignOptions({ columnTypes });
48
51
  }
49
52
  /**
50
53
  * Explicitly specify the runtime type.
@@ -53,72 +56,72 @@ class PropertyOptionsBuilder {
53
56
  * @see https://mikro-orm.io/docs/custom-types
54
57
  */
55
58
  type(type) {
56
- return new PropertyOptionsBuilder({ ...this['~options'], type });
59
+ return this.assignOptions({ type });
57
60
  }
58
61
  /**
59
62
  * 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`.
60
63
  * 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`.
61
64
  */
62
65
  runtimeType(runtimeType) {
63
- return new PropertyOptionsBuilder({ ...this['~options'], runtimeType });
66
+ return this.assignOptions({ runtimeType });
64
67
  }
65
68
  /**
66
69
  * 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)
67
70
  */
68
71
  length(length) {
69
- return new PropertyOptionsBuilder({ ...this['~options'], length });
72
+ return this.assignOptions({ length });
70
73
  }
71
74
  /**
72
75
  * Set precision of database column to represent the number of significant digits. (SQL only)
73
76
  */
74
77
  precision(precision) {
75
- return new PropertyOptionsBuilder({ ...this['~options'], precision });
78
+ return this.assignOptions({ precision });
76
79
  }
77
80
  /**
78
81
  * Set scale of database column to represents the number of digits after the decimal point. (SQL only)
79
82
  */
80
83
  scale(scale) {
81
- return new PropertyOptionsBuilder({ ...this['~options'], scale });
84
+ return this.assignOptions({ scale });
82
85
  }
83
86
  /**
84
87
  * Explicitly specify the auto increment of the primary key.
85
88
  */
86
89
  autoincrement(autoincrement = true) {
87
- return new PropertyOptionsBuilder({ ...this['~options'], autoincrement });
90
+ return this.assignOptions({ autoincrement });
88
91
  }
89
92
  /**
90
93
  * Add the property to the `returning` statement.
91
94
  */
92
95
  returning(returning = true) {
93
- return new PropertyOptionsBuilder({ ...this['~options'], returning });
96
+ return this.assignOptions({ returning });
94
97
  }
95
98
  /**
96
99
  * Automatically set the property value when entity gets created, executed during flush operation.
97
100
  * @param entity
98
101
  */
99
102
  onCreate(onCreate) {
100
- return new PropertyOptionsBuilder({ ...this['~options'], onCreate });
103
+ return this.assignOptions({ onCreate });
101
104
  }
102
105
  /**
103
106
  * Automatically update the property value every time entity gets updated, executed during flush operation.
104
107
  * @param entity
105
108
  */
106
109
  onUpdate(onUpdate) {
107
- return new PropertyOptionsBuilder({ ...this['~options'], onUpdate });
110
+ return this.assignOptions({ onUpdate });
108
111
  }
109
112
  /**
110
113
  * Specify default column value for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}.
111
114
  * This is a runtime value, assignable to the entity property. (SQL only)
112
115
  */
113
116
  default(defaultValue) {
114
- return new PropertyOptionsBuilder({ ...this['~options'], default: defaultValue });
117
+ return this.assignOptions({ default: defaultValue });
115
118
  }
116
119
  /**
117
120
  * Specify SQL functions for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}. (SQL only)
118
121
  * Since v4 you should use defaultRaw for SQL functions. e.g. now()
119
122
  */
120
123
  defaultRaw(defaultRaw) {
121
- return new PropertyOptionsBuilder({ ...this['~options'], defaultRaw });
124
+ return this.assignOptions({ defaultRaw });
122
125
  }
123
126
  /**
124
127
  * Set to map some SQL snippet for the entity.
@@ -126,43 +129,43 @@ class PropertyOptionsBuilder {
126
129
  * @see https://mikro-orm.io/docs/defining-entities#formulas Formulas
127
130
  */
128
131
  formula(formula) {
129
- return new PropertyOptionsBuilder({ ...this['~options'], formula });
132
+ return this.assignOptions({ formula });
130
133
  }
131
134
  /**
132
135
  * For generated columns. This will be appended to the column type after the `generated always` clause.
133
136
  */
134
137
  generated(generated) {
135
- return new PropertyOptionsBuilder({ ...this['~options'], generated });
138
+ return this.assignOptions({ generated });
136
139
  }
137
140
  /**
138
141
  * Set column as nullable for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}.
139
142
  */
140
143
  nullable(nullable = true) {
141
- return new PropertyOptionsBuilder({ ...this['~options'], nullable });
144
+ return this.assignOptions({ nullable });
142
145
  }
143
146
  /**
144
147
  * Set column as unsigned for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}. (SQL only)
145
148
  */
146
149
  unsigned(unsigned = true) {
147
- return new PropertyOptionsBuilder({ ...this['~options'], unsigned });
150
+ return this.assignOptions({ unsigned });
148
151
  }
149
152
  /**
150
153
  * Set false to define {@link https://mikro-orm.io/docs/serializing#shadow-properties Shadow Property}.
151
154
  */
152
155
  persist(persist = true) {
153
- return new PropertyOptionsBuilder({ ...this['~options'], persist });
156
+ return this.assignOptions({ persist });
154
157
  }
155
158
  /**
156
159
  * Set false to disable hydration of this property. Useful for persisted getters.
157
160
  */
158
161
  hydrate(hydrate = true) {
159
- return new PropertyOptionsBuilder({ ...this['~options'], hydrate });
162
+ return this.assignOptions({ hydrate });
160
163
  }
161
164
  /**
162
165
  * 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.
163
166
  */
164
167
  ref(ref = true) {
165
- return new PropertyOptionsBuilder({ ...this['~options'], ref });
168
+ return this.assignOptions({ ref });
166
169
  }
167
170
  /**
168
171
  * Set false to disable change tracking on a property level.
@@ -170,37 +173,37 @@ class PropertyOptionsBuilder {
170
173
  * @see https://mikro-orm.io/docs/unit-of-work#change-tracking-and-performance-considerations
171
174
  */
172
175
  trackChanges(trackChanges = true) {
173
- return new PropertyOptionsBuilder({ ...this['~options'], trackChanges });
176
+ return this.assignOptions({ trackChanges });
174
177
  }
175
178
  /**
176
179
  * Set to true to omit the property when {@link https://mikro-orm.io/docs/serializing Serializing}.
177
180
  */
178
181
  hidden(hidden = true) {
179
- return new PropertyOptionsBuilder({ ...this['~options'], hidden });
182
+ return this.assignOptions({ hidden });
180
183
  }
181
184
  /**
182
185
  * Set to true to enable {@link https://mikro-orm.io/docs/transactions#optimistic-locking Optimistic Locking} via version field. (SQL only)
183
186
  */
184
187
  version(version = true) {
185
- return new PropertyOptionsBuilder({ ...this['~options'], version });
188
+ return this.assignOptions({ version });
186
189
  }
187
190
  /**
188
191
  * Set to true to enable {@link https://mikro-orm.io/docs/transactions#optimistic-locking Optimistic Locking} via concurrency fields.
189
192
  */
190
193
  concurrencyCheck(concurrencyCheck = true) {
191
- return new PropertyOptionsBuilder({ ...this['~options'], concurrencyCheck });
194
+ return this.assignOptions({ concurrencyCheck });
192
195
  }
193
196
  /**
194
197
  * Explicitly specify index on a property.
195
198
  */
196
199
  index(index = true) {
197
- return new PropertyOptionsBuilder({ ...this['~options'], index });
200
+ return this.assignOptions({ index });
198
201
  }
199
202
  /**
200
203
  * Set column as unique for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}. (SQL only)
201
204
  */
202
205
  unique(unique = true) {
203
- return new PropertyOptionsBuilder({ ...this['~options'], unique });
206
+ return this.assignOptions({ unique });
204
207
  }
205
208
  /**
206
209
  * Specify column with check constraints. (Postgres driver only)
@@ -208,7 +211,7 @@ class PropertyOptionsBuilder {
208
211
  * @see https://mikro-orm.io/docs/defining-entities#check-constraints
209
212
  */
210
213
  check(check) {
211
- return new PropertyOptionsBuilder({ ...this['~options'], check });
214
+ return this.assignOptions({ check });
212
215
  }
213
216
  /**
214
217
  * Set to omit the property from the select clause for lazy loading.
@@ -216,7 +219,7 @@ class PropertyOptionsBuilder {
216
219
  * @see https://mikro-orm.io/docs/defining-entities#lazy-scalar-properties
217
220
  */
218
221
  lazy(lazy = true, ref = true) {
219
- return new PropertyOptionsBuilder({ ...this['~options'], lazy, ref });
222
+ return this.assignOptions({ lazy, ref });
220
223
  }
221
224
  /**
222
225
  * Set true to define entity's unique primary key identifier.
@@ -224,7 +227,7 @@ class PropertyOptionsBuilder {
224
227
  * @see https://mikro-orm.io/docs/decorators#primarykey
225
228
  */
226
229
  primary(primary = true) {
227
- return new PropertyOptionsBuilder({ ...this['~options'], primary });
230
+ return this.assignOptions({ primary });
228
231
  }
229
232
  /**
230
233
  * Set true to define the properties as setter. (virtual)
@@ -238,7 +241,7 @@ class PropertyOptionsBuilder {
238
241
  * ```
239
242
  */
240
243
  setter(setter = true) {
241
- return new PropertyOptionsBuilder({ ...this['~options'], setter });
244
+ return this.assignOptions({ setter });
242
245
  }
243
246
  /**
244
247
  * Set true to define the properties as getter. (virtual)
@@ -252,7 +255,7 @@ class PropertyOptionsBuilder {
252
255
  * ```
253
256
  */
254
257
  getter(getter = true) {
255
- return new PropertyOptionsBuilder({ ...this['~options'], getter });
258
+ return this.assignOptions({ getter });
256
259
  }
257
260
  /**
258
261
  * When defining a property over a method (not a getter, a regular function), you can use this option to point
@@ -267,7 +270,7 @@ class PropertyOptionsBuilder {
267
270
  * ```
268
271
  */
269
272
  getterName(getterName) {
270
- return new PropertyOptionsBuilder({ ...this['~options'], getterName });
273
+ return this.assignOptions({ getterName });
271
274
  }
272
275
  /**
273
276
  * Set to define serialized primary key for MongoDB. (virtual)
@@ -276,7 +279,7 @@ class PropertyOptionsBuilder {
276
279
  * @see https://mikro-orm.io/docs/decorators#serializedprimarykey
277
280
  */
278
281
  serializedPrimaryKey(serializedPrimaryKey = true) {
279
- return new PropertyOptionsBuilder({ ...this['~options'], serializedPrimaryKey });
282
+ return this.assignOptions({ serializedPrimaryKey });
280
283
  }
281
284
  /**
282
285
  * Set to use serialize property. Allow to specify a callback that will be used when serializing a property.
@@ -284,36 +287,36 @@ class PropertyOptionsBuilder {
284
287
  * @see https://mikro-orm.io/docs/serializing#property-serializers
285
288
  */
286
289
  serializer(serializer) {
287
- return new PropertyOptionsBuilder({ ...this['~options'], serializer });
290
+ return this.assignOptions({ serializer });
288
291
  }
289
292
  /**
290
293
  * Specify name of key for the serialized value.
291
294
  */
292
295
  serializedName(serializedName) {
293
- return new PropertyOptionsBuilder({ ...this['~options'], serializedName });
296
+ return this.assignOptions({ serializedName });
294
297
  }
295
298
  /**
296
299
  * Specify serialization groups for `serialize()` calls. If a property does not specify any group, it will be included,
297
300
  * otherwise only properties with a matching group are included.
298
301
  */
299
302
  groups(...groups) {
300
- return new PropertyOptionsBuilder({ ...this['~options'], groups });
303
+ return this.assignOptions({ groups });
301
304
  }
302
305
  /**
303
306
  * Specify a custom order based on the values. (SQL only)
304
307
  */
305
308
  customOrder(...customOrder) {
306
- return new PropertyOptionsBuilder({ ...this['~options'], customOrder });
309
+ return this.assignOptions({ customOrder });
307
310
  }
308
311
  /**
309
312
  * Specify comment of column for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}. (SQL only)
310
313
  */
311
314
  comment(comment) {
312
- return new PropertyOptionsBuilder({ ...this['~options'], comment });
315
+ return this.assignOptions({ comment });
313
316
  }
314
317
  /** mysql only */
315
318
  extra(extra) {
316
- return new PropertyOptionsBuilder({ ...this['~options'], extra });
319
+ return this.assignOptions({ extra });
317
320
  }
318
321
  /**
319
322
  * Set to avoid a perpetual diff from the {@link https://mikro-orm.io/docs/schema-generator Schema Generator} when columns are generated.
@@ -321,10 +324,10 @@ class PropertyOptionsBuilder {
321
324
  * @see https://mikro-orm.io/docs/defining-entities#sql-generated-columns
322
325
  */
323
326
  ignoreSchemaChanges(...ignoreSchemaChanges) {
324
- return new PropertyOptionsBuilder({ ...this['~options'], ignoreSchemaChanges });
327
+ return this.assignOptions({ ignoreSchemaChanges });
325
328
  }
326
329
  $type() {
327
- return new PropertyOptionsBuilder({ ...this['~options'] });
330
+ return this.assignOptions({});
328
331
  }
329
332
  }
330
333
  exports.PropertyOptionsBuilder = PropertyOptionsBuilder;
@@ -334,12 +337,15 @@ class EnumOptionsBuilder extends PropertyOptionsBuilder {
334
337
  super(options);
335
338
  this['~options'] = options;
336
339
  }
340
+ assignOptions(options) {
341
+ return new EnumOptionsBuilder({ ...this['~options'], ...options });
342
+ }
337
343
  array(array = true) {
338
- return new EnumOptionsBuilder({ ...this['~options'], array });
344
+ return this.assignOptions({ array });
339
345
  }
340
346
  /** for postgres, by default it uses text column with check constraint */
341
347
  nativeEnumName(nativeEnumName) {
342
- return new EnumOptionsBuilder({ ...this['~options'], nativeEnumName });
348
+ return this.assignOptions({ nativeEnumName });
343
349
  }
344
350
  }
345
351
  exports.EnumOptionsBuilder = EnumOptionsBuilder;
@@ -349,17 +355,20 @@ class EmbeddedOptionsBuilder extends PropertyOptionsBuilder {
349
355
  super(options);
350
356
  this['~options'] = options;
351
357
  }
358
+ assignOptions(options) {
359
+ return new EmbeddedOptionsBuilder({ ...this['~options'], ...options });
360
+ }
352
361
  prefix(prefix) {
353
- return new EmbeddedOptionsBuilder({ ...this['~options'], prefix });
362
+ return this.assignOptions({ prefix });
354
363
  }
355
364
  prefixMode(prefixMode) {
356
- return new EmbeddedOptionsBuilder({ ...this['~options'], prefixMode });
365
+ return this.assignOptions({ prefixMode });
357
366
  }
358
367
  object(object = true) {
359
- return new EmbeddedOptionsBuilder({ ...this['~options'], object });
368
+ return this.assignOptions({ object });
360
369
  }
361
370
  array(array = true) {
362
- return new EmbeddedOptionsBuilder({ ...this['~options'], array });
371
+ return this.assignOptions({ array });
363
372
  }
364
373
  }
365
374
  exports.EmbeddedOptionsBuilder = EmbeddedOptionsBuilder;
@@ -371,31 +380,15 @@ class ReferenceOptionsBuilder extends PropertyOptionsBuilder {
371
380
  }
372
381
  /** Set what actions on owning entity should be cascaded to the relationship. Defaults to [Cascade.PERSIST, Cascade.MERGE] (see {@doclink cascading}). */
373
382
  cascade(...cascade) {
374
- return new ReferenceOptionsBuilder({ ...this['~options'], cascade });
383
+ return this.assignOptions({ cascade });
375
384
  }
376
385
  /** Always load the relationship. Discouraged for use with to-many relations for performance reasons. */
377
386
  eager(eager = true) {
378
- return new ReferenceOptionsBuilder({ ...this['~options'], eager });
387
+ return this.assignOptions({ eager });
379
388
  }
380
389
  /** Override the default loading strategy for this property. This option has precedence over the global `loadStrategy`, but can be overridden by `FindOptions.strategy`. */
381
390
  strategy(strategy) {
382
- return new ReferenceOptionsBuilder({ ...this['~options'], strategy });
383
- }
384
- /**
385
- * @internal
386
- * re-declare to override type inference
387
- */
388
- /* istanbul ignore next */
389
- ref(ref = true) {
390
- return new ReferenceOptionsBuilder({ ...this['~options'], ref });
391
- }
392
- /**
393
- * @internal
394
- * re-declare to override type inference
395
- */
396
- /* istanbul ignore next */
397
- primary(primary = true) {
398
- return new ReferenceOptionsBuilder({ ...this['~options'], primary });
391
+ return this.assignOptions({ strategy });
399
392
  }
400
393
  }
401
394
  exports.ReferenceOptionsBuilder = ReferenceOptionsBuilder;
@@ -405,73 +398,76 @@ class ManyToManyOptionsBuilder extends ReferenceOptionsBuilder {
405
398
  super(options);
406
399
  this['~options'] = options;
407
400
  }
401
+ assignOptions(options) {
402
+ return new ManyToManyOptionsBuilder({ ...this['~options'], ...options });
403
+ }
408
404
  /** 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. */
409
405
  owner(owner = true) {
410
- return new ManyToManyOptionsBuilder({ ...this['~options'], owner });
406
+ return this.assignOptions({ owner });
411
407
  }
412
408
  /** Point to the inverse side property name. */
413
409
  inversedBy(inversedBy) {
414
- return new ManyToManyOptionsBuilder({ ...this['~options'], inversedBy });
410
+ return this.assignOptions({ inversedBy });
415
411
  }
416
412
  /** Point to the owning side property name. */
417
413
  mappedBy(mappedBy) {
418
- return new ManyToManyOptionsBuilder({ ...this['~options'], mappedBy });
414
+ return this.assignOptions({ mappedBy });
419
415
  }
420
416
  /** Condition for {@doclink collections#declarative-partial-loading | Declarative partial loading}. */
421
417
  where(...where) {
422
- return new ManyToManyOptionsBuilder({ ...this['~options'], where: where });
418
+ return this.assignOptions({ where });
423
419
  }
424
420
  /** Set default ordering. */
425
421
  orderBy(...orderBy) {
426
- return new ManyToManyOptionsBuilder({ ...this['~options'], orderBy });
422
+ return this.assignOptions({ orderBy });
427
423
  }
428
424
  /** Force stable insertion order of items in the collection (see {@doclink collections | Collections}). */
429
425
  fixedOrder(fixedOrder = true) {
430
- return new ManyToManyOptionsBuilder({ ...this['~options'], fixedOrder });
426
+ return this.assignOptions({ fixedOrder });
431
427
  }
432
428
  /** Override default order column name (`id`) for fixed ordering. */
433
429
  fixedOrderColumn(fixedOrderColumn) {
434
- return new ManyToManyOptionsBuilder({ ...this['~options'], fixedOrderColumn });
430
+ return this.assignOptions({ fixedOrderColumn });
435
431
  }
436
432
  /** Override default name for pivot table (see {@doclink naming-strategy | Naming Strategy}). */
437
433
  pivotTable(pivotTable) {
438
- return new ManyToManyOptionsBuilder({ ...this['~options'], pivotTable });
434
+ return this.assignOptions({ pivotTable });
439
435
  }
440
436
  /** Set pivot entity for this relation (see {@doclink collections#custom-pivot-table-entity | Custom pivot table entity}). */
441
437
  pivotEntity(pivotEntity) {
442
- return new ManyToManyOptionsBuilder({ ...this['~options'], pivotEntity });
438
+ return this.assignOptions({ pivotEntity });
443
439
  }
444
440
  /** 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. */
445
441
  joinColumn(joinColumn) {
446
- return new ManyToManyOptionsBuilder({ ...this['~options'], joinColumn });
442
+ return this.assignOptions({ joinColumn });
447
443
  }
448
444
  /** 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. */
449
445
  joinColumns(...joinColumns) {
450
- return new ManyToManyOptionsBuilder({ ...this['~options'], joinColumns });
446
+ return this.assignOptions({ joinColumns });
451
447
  }
452
448
  /** 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. */
453
449
  inverseJoinColumn(inverseJoinColumn) {
454
- return new ManyToManyOptionsBuilder({ ...this['~options'], inverseJoinColumn });
450
+ return this.assignOptions({ inverseJoinColumn });
455
451
  }
456
452
  /** 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. */
457
453
  inverseJoinColumns(...inverseJoinColumns) {
458
- return new ManyToManyOptionsBuilder({ ...this['~options'], inverseJoinColumns });
454
+ return this.assignOptions({ inverseJoinColumns });
459
455
  }
460
456
  /** 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. */
461
457
  referenceColumnName(referenceColumnName) {
462
- return new ManyToManyOptionsBuilder({ ...this['~options'], referenceColumnName });
458
+ return this.assignOptions({ referenceColumnName });
463
459
  }
464
460
  /** 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. */
465
461
  referencedColumnNames(...referencedColumnNames) {
466
- return new ManyToManyOptionsBuilder({ ...this['~options'], referencedColumnNames });
462
+ return this.assignOptions({ referencedColumnNames });
467
463
  }
468
464
  /** What to do when the target entity gets deleted. */
469
465
  deleteRule(deleteRule) {
470
- return new ManyToManyOptionsBuilder({ ...this['~options'], deleteRule });
466
+ return this.assignOptions({ deleteRule });
471
467
  }
472
468
  /** What to do when the reference to the target entity gets updated. */
473
469
  updateRule(updateRule) {
474
- return new ManyToManyOptionsBuilder({ ...this['~options'], updateRule });
470
+ return this.assignOptions({ updateRule });
475
471
  }
476
472
  }
477
473
  exports.ManyToManyOptionsBuilder = ManyToManyOptionsBuilder;
@@ -481,53 +477,48 @@ class ManyToOneOptionsBuilder extends ReferenceOptionsBuilder {
481
477
  super(options);
482
478
  this['~options'] = options;
483
479
  }
480
+ assignOptions(options) {
481
+ return new ManyToOneOptionsBuilder({ ...this['~options'], ...options });
482
+ }
484
483
  /** Point to the inverse side property name. */
485
484
  inversedBy(inversedBy) {
486
- return new ManyToOneOptionsBuilder({ ...this['~options'], inversedBy });
487
- }
488
- /** Wrap the entity in {@apilink Reference} wrapper. */
489
- ref(ref = true) {
490
- return new ManyToOneOptionsBuilder({ ...this['~options'], ref });
491
- }
492
- /** Use this relation as a primary key. */
493
- primary(primary = true) {
494
- return new ManyToOneOptionsBuilder({ ...this['~options'], primary });
485
+ return this.assignOptions({ inversedBy });
495
486
  }
496
487
  /** Map this relation to the primary key value instead of an entity. */
497
488
  mapToPk(mapToPk = true) {
498
- return new ManyToOneOptionsBuilder({ ...this['~options'], mapToPk });
489
+ return this.assignOptions({ mapToPk });
499
490
  }
500
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. */
501
492
  joinColumn(joinColumn) {
502
- return new ManyToOneOptionsBuilder({ ...this['~options'], joinColumn });
493
+ return this.assignOptions({ joinColumn });
503
494
  }
504
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. */
505
496
  joinColumns(...joinColumns) {
506
- return new ManyToOneOptionsBuilder({ ...this['~options'], joinColumns });
497
+ return this.assignOptions({ joinColumns });
507
498
  }
508
499
  /** 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. */
509
500
  ownColumns(...ownColumns) {
510
- return new ManyToOneOptionsBuilder({ ...this['~options'], ownColumns });
501
+ return this.assignOptions({ ownColumns });
511
502
  }
512
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. */
513
504
  referenceColumnName(referenceColumnName) {
514
- return new ManyToOneOptionsBuilder({ ...this['~options'], referenceColumnName });
505
+ return this.assignOptions({ referenceColumnName });
515
506
  }
516
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. */
517
508
  referencedColumnNames(...referencedColumnNames) {
518
- return new ManyToOneOptionsBuilder({ ...this['~options'], referencedColumnNames });
509
+ return this.assignOptions({ referencedColumnNames });
519
510
  }
520
511
  /** What to do when the target entity gets deleted. */
521
512
  deleteRule(deleteRule) {
522
- return new ManyToOneOptionsBuilder({ ...this['~options'], deleteRule });
513
+ return this.assignOptions({ deleteRule });
523
514
  }
524
515
  /** What to do when the reference to the target entity gets updated. */
525
516
  updateRule(updateRule) {
526
- return new ManyToOneOptionsBuilder({ ...this['~options'], updateRule });
517
+ return this.assignOptions({ updateRule });
527
518
  }
528
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. */
529
520
  deferMode(deferMode) {
530
- return new ManyToOneOptionsBuilder({ ...this['~options'], deferMode });
521
+ return this.assignOptions({ deferMode });
531
522
  }
532
523
  }
533
524
  exports.ManyToOneOptionsBuilder = ManyToOneOptionsBuilder;
@@ -537,41 +528,44 @@ class OneToManyOptionsBuilder extends ReferenceOptionsBuilder {
537
528
  super(options);
538
529
  this['~options'] = options;
539
530
  }
531
+ assignOptions(options) {
532
+ return new OneToManyOptionsBuilder({ ...this['~options'], ...options });
533
+ }
540
534
  /** Remove the entity when it gets disconnected from the relationship (see {@doclink cascading | Cascading}). */
541
535
  orphanRemoval(orphanRemoval = true) {
542
- return new OneToManyOptionsBuilder({ ...this['~options'], orphanRemoval });
536
+ return this.assignOptions({ orphanRemoval });
543
537
  }
544
538
  /** Set default ordering. */
545
539
  orderBy(orderBy) {
546
- return new OneToManyOptionsBuilder({ ...this['~options'], orderBy });
540
+ return this.assignOptions({ orderBy });
547
541
  }
548
542
  /** Condition for {@doclink collections#declarative-partial-loading | Declarative partial loading}. */
549
543
  where(where) {
550
- return new OneToManyOptionsBuilder({ ...this['~options'], where });
544
+ return this.assignOptions({ where });
551
545
  }
552
546
  /** 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. */
553
547
  joinColumn(joinColumn) {
554
- return new OneToManyOptionsBuilder({ ...this['~options'], joinColumn });
548
+ return this.assignOptions({ joinColumn });
555
549
  }
556
550
  /** 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. */
557
551
  joinColumns(...joinColumns) {
558
- return new OneToManyOptionsBuilder({ ...this['~options'], joinColumns });
552
+ return this.assignOptions({ joinColumns });
559
553
  }
560
554
  /** 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. */
561
555
  inverseJoinColumn(inverseJoinColumn) {
562
- return new OneToManyOptionsBuilder({ ...this['~options'], inverseJoinColumn });
556
+ return this.assignOptions({ inverseJoinColumn });
563
557
  }
564
558
  /** 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. */
565
559
  inverseJoinColumns(...inverseJoinColumns) {
566
- return new OneToManyOptionsBuilder({ ...this['~options'], inverseJoinColumns });
560
+ return this.assignOptions({ inverseJoinColumns });
567
561
  }
568
562
  /** 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. */
569
563
  referenceColumnName(referenceColumnName) {
570
- return new OneToManyOptionsBuilder({ ...this['~options'], referenceColumnName });
564
+ return this.assignOptions({ referenceColumnName });
571
565
  }
572
566
  /** 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. */
573
567
  referencedColumnNames(...referencedColumnNames) {
574
- return new OneToManyOptionsBuilder({ ...this['~options'], referencedColumnNames });
568
+ return this.assignOptions({ referencedColumnNames });
575
569
  }
576
570
  }
577
571
  exports.OneToManyOptionsBuilder = OneToManyOptionsBuilder;
@@ -592,41 +586,36 @@ class OneToOneOptionsBuilder extends ReferenceOptionsBuilder {
592
586
  super(options);
593
587
  this['~options'] = options;
594
588
  }
589
+ assignOptions(options) {
590
+ return new OneToOneOptionsBuilder({ ...this['~options'], ...options });
591
+ }
595
592
  /** 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. */
596
593
  owner(owner = true) {
597
- return new OneToOneOptionsBuilder({ ...this['~options'], owner });
594
+ return this.assignOptions({ owner });
598
595
  }
599
596
  /** Point to the inverse side property name. */
600
597
  inversedBy(inversedBy) {
601
- return new OneToOneOptionsBuilder({ ...this['~options'], inversedBy });
602
- }
603
- /** Wrap the entity in {@apilink Reference} wrapper. */
604
- ref(ref = true) {
605
- return new OneToOneOptionsBuilder({ ...this['~options'], ref });
606
- }
607
- /** Use this relation as a primary key. */
608
- primary(primary = true) {
609
- return new OneToOneOptionsBuilder({ ...this['~options'], primary });
598
+ return this.assignOptions({ inversedBy });
610
599
  }
611
600
  /** Map this relation to the primary key value instead of an entity. */
612
601
  mapToPk(mapToPk = true) {
613
- return new OneToOneOptionsBuilder({ ...this['~options'], mapToPk });
602
+ return this.assignOptions({ mapToPk });
614
603
  }
615
604
  /** 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. */
616
605
  ownColumns(...ownColumns) {
617
- return new OneToOneOptionsBuilder({ ...this['~options'], ownColumns });
606
+ return this.assignOptions({ ownColumns });
618
607
  }
619
608
  /** What to do when the target entity gets deleted. */
620
609
  deleteRule(deleteRule) {
621
- return new OneToOneOptionsBuilder({ ...this['~options'], deleteRule });
610
+ return this.assignOptions({ deleteRule });
622
611
  }
623
612
  /** What to do when the reference to the target entity gets updated. */
624
613
  updateRule(updateRule) {
625
- return new OneToOneOptionsBuilder({ ...this['~options'], updateRule });
614
+ return this.assignOptions({ updateRule });
626
615
  }
627
616
  /** 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. */
628
617
  deferMode(deferMode) {
629
- return new OneToOneOptionsBuilder({ ...this['~options'], deferMode });
618
+ return this.assignOptions({ deferMode });
630
619
  }
631
620
  }
632
621
  exports.OneToOneOptionsBuilder = OneToOneOptionsBuilder;
@@ -675,8 +664,8 @@ function defineEntity(meta) {
675
664
  const { properties: propertiesOrGetter, ...options } = meta;
676
665
  const propertyOptions = typeof propertiesOrGetter === 'function' ? propertiesOrGetter(propertyBuilders) : propertiesOrGetter;
677
666
  const properties = {};
667
+ const values = new Map();
678
668
  for (const [key, builder] of Object.entries(propertyOptions)) {
679
- const values = new Map();
680
669
  if (typeof builder === 'function') {
681
670
  Object.defineProperty(properties, key, {
682
671
  get: () => {