@mikro-orm/core 7.0.0-rc.3 → 7.0.1-dev.0

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 (94) hide show
  1. package/EntityManager.d.ts +2 -15
  2. package/EntityManager.js +155 -152
  3. package/MikroORM.d.ts +4 -6
  4. package/MikroORM.js +20 -20
  5. package/README.md +5 -4
  6. package/cache/FileCacheAdapter.d.ts +1 -5
  7. package/cache/FileCacheAdapter.js +22 -22
  8. package/cache/GeneratedCacheAdapter.d.ts +1 -1
  9. package/cache/GeneratedCacheAdapter.js +6 -6
  10. package/cache/MemoryCacheAdapter.d.ts +1 -2
  11. package/cache/MemoryCacheAdapter.js +8 -8
  12. package/cache/index.d.ts +1 -1
  13. package/cache/index.js +0 -1
  14. package/connections/Connection.d.ts +1 -0
  15. package/connections/Connection.js +27 -11
  16. package/drivers/DatabaseDriver.d.ts +0 -2
  17. package/drivers/DatabaseDriver.js +2 -4
  18. package/entity/Collection.d.ts +1 -9
  19. package/entity/Collection.js +95 -105
  20. package/entity/EntityFactory.d.ts +1 -8
  21. package/entity/EntityFactory.js +48 -48
  22. package/entity/EntityLoader.d.ts +1 -3
  23. package/entity/EntityLoader.js +36 -39
  24. package/entity/Reference.d.ts +1 -2
  25. package/entity/Reference.js +11 -11
  26. package/entity/WrappedEntity.d.ts +4 -2
  27. package/entity/defineEntity.d.ts +18 -73
  28. package/enums.d.ts +2 -1
  29. package/enums.js +1 -0
  30. package/errors.d.ts +11 -11
  31. package/errors.js +3 -13
  32. package/events/EventManager.d.ts +1 -4
  33. package/events/EventManager.js +25 -22
  34. package/events/index.d.ts +1 -1
  35. package/events/index.js +0 -1
  36. package/exceptions.js +8 -6
  37. package/hydration/ObjectHydrator.d.ts +1 -2
  38. package/hydration/ObjectHydrator.js +16 -16
  39. package/logging/DefaultLogger.js +3 -2
  40. package/logging/Logger.d.ts +2 -1
  41. package/logging/colors.js +1 -1
  42. package/logging/index.d.ts +1 -1
  43. package/logging/index.js +0 -1
  44. package/metadata/EntitySchema.d.ts +1 -1
  45. package/metadata/MetadataDiscovery.d.ts +1 -9
  46. package/metadata/MetadataDiscovery.js +162 -149
  47. package/metadata/MetadataStorage.d.ts +1 -5
  48. package/metadata/MetadataStorage.js +36 -36
  49. package/metadata/discover-entities.js +1 -1
  50. package/metadata/index.d.ts +1 -1
  51. package/metadata/index.js +0 -1
  52. package/naming-strategy/AbstractNamingStrategy.js +1 -1
  53. package/naming-strategy/EntityCaseNamingStrategy.js +1 -1
  54. package/naming-strategy/index.d.ts +1 -1
  55. package/naming-strategy/index.js +0 -1
  56. package/package.json +1 -1
  57. package/platforms/Platform.d.ts +23 -1
  58. package/platforms/Platform.js +57 -4
  59. package/serialization/EntitySerializer.js +1 -1
  60. package/serialization/EntityTransformer.js +4 -1
  61. package/serialization/SerializationContext.d.ts +4 -8
  62. package/serialization/SerializationContext.js +20 -15
  63. package/types/UuidType.d.ts +2 -0
  64. package/types/UuidType.js +14 -2
  65. package/types/index.d.ts +2 -1
  66. package/typings.d.ts +12 -1
  67. package/unit-of-work/ChangeSetComputer.d.ts +1 -6
  68. package/unit-of-work/ChangeSetComputer.js +21 -21
  69. package/unit-of-work/ChangeSetPersister.d.ts +1 -9
  70. package/unit-of-work/ChangeSetPersister.js +52 -52
  71. package/unit-of-work/CommitOrderCalculator.d.ts +1 -4
  72. package/unit-of-work/CommitOrderCalculator.js +13 -13
  73. package/unit-of-work/IdentityMap.d.ts +2 -5
  74. package/unit-of-work/IdentityMap.js +18 -18
  75. package/unit-of-work/UnitOfWork.d.ts +5 -19
  76. package/unit-of-work/UnitOfWork.js +182 -174
  77. package/utils/AbstractMigrator.d.ts +1 -1
  78. package/utils/AbstractMigrator.js +7 -7
  79. package/utils/Configuration.d.ts +90 -189
  80. package/utils/Configuration.js +94 -78
  81. package/utils/Cursor.d.ts +3 -3
  82. package/utils/Cursor.js +4 -4
  83. package/utils/EntityComparator.d.ts +8 -15
  84. package/utils/EntityComparator.js +49 -49
  85. package/utils/QueryHelper.d.ts +16 -1
  86. package/utils/QueryHelper.js +70 -24
  87. package/utils/RawQueryFragment.d.ts +4 -4
  88. package/utils/TransactionManager.js +1 -2
  89. package/utils/Utils.d.ts +1 -1
  90. package/utils/Utils.js +5 -4
  91. package/utils/clone.js +5 -0
  92. package/utils/fs-utils.d.ts +3 -17
  93. package/utils/fs-utils.js +1 -1
  94. package/utils/upsert-utils.js +1 -1
@@ -2,8 +2,6 @@ import type { NamingStrategy } from '../naming-strategy/NamingStrategy.js';
2
2
  import { type CacheAdapter, type SyncCacheAdapter } from '../cache/CacheAdapter.js';
3
3
  import type { EntityRepository } from '../entity/EntityRepository.js';
4
4
  import type { AnyEntity, CompiledFunctions, Constructor, Dictionary, EnsureDatabaseOptions, EntityClass, EntityMetadata, FilterDef, GenerateOptions, Highlighter, HydratorConstructor, IHydrator, IMigrationGenerator, IPrimaryKey, MaybePromise, Migration, MigrationObject, Seeder, SeederObject } from '../typings.js';
5
- import { ObjectHydrator } from '../hydration/ObjectHydrator.js';
6
- import { NullHighlighter } from '../utils/NullHighlighter.js';
7
5
  import { type Logger, type LoggerNamespace, type LoggerOptions } from '../logging/Logger.js';
8
6
  import type { EntityManager } from '../EntityManager.js';
9
7
  import type { Platform } from '../platforms/Platform.js';
@@ -13,152 +11,36 @@ import type { MetadataStorage } from '../metadata/MetadataStorage.js';
13
11
  import type { EventSubscriber } from '../events/EventSubscriber.js';
14
12
  import type { AssignOptions } from '../entity/EntityAssigner.js';
15
13
  import type { EntityManagerType, IDatabaseDriver } from '../drivers/IDatabaseDriver.js';
16
- import { NotFoundError } from '../errors.js';
17
14
  import { DataloaderType, FlushMode, LoadStrategy, PopulateHint, type EmbeddedPrefixMode } from '../enums.js';
18
- import { MemoryCacheAdapter } from '../cache/MemoryCacheAdapter.js';
19
15
  import { EntityComparator } from './EntityComparator.js';
20
16
  import type { Type } from '../types/Type.js';
21
17
  import type { MikroORM } from '../MikroORM.js';
22
- declare const DEFAULTS: {
23
- readonly pool: {};
24
- readonly entities: readonly [];
25
- readonly entitiesTs: readonly [];
26
- readonly extensions: readonly [];
27
- readonly subscribers: readonly [];
28
- readonly filters: {};
29
- readonly discovery: {
30
- readonly warnWhenNoEntities: true;
31
- readonly checkDuplicateTableNames: true;
32
- readonly checkDuplicateFieldNames: true;
33
- readonly checkDuplicateEntities: true;
34
- readonly checkNonPersistentCompositeProps: true;
35
- readonly inferDefaultValues: true;
36
- };
37
- readonly validateRequired: true;
38
- readonly context: (name: string) => EntityManager<IDatabaseDriver<import("../index.js").Connection>> | undefined;
39
- readonly contextName: "default";
40
- readonly allowGlobalContext: false;
41
- readonly logger: (message?: any, ...optionalParams: any[]) => void;
42
- readonly colors: true;
43
- readonly findOneOrFailHandler: (entityName: string, where: Dictionary | IPrimaryKey) => NotFoundError<Partial<any>>;
44
- readonly findExactlyOneOrFailHandler: (entityName: string, where: Dictionary | IPrimaryKey) => NotFoundError<Partial<any>>;
45
- readonly baseDir: string;
46
- readonly hydrator: typeof ObjectHydrator;
47
- readonly flushMode: FlushMode.AUTO;
48
- readonly loadStrategy: LoadStrategy.BALANCED;
49
- readonly dataloader: DataloaderType.NONE;
50
- readonly populateWhere: PopulateHint.ALL;
51
- readonly ignoreUndefinedInQuery: false;
52
- readonly onQuery: (sql: string) => string;
53
- readonly autoJoinOneToOneOwner: true;
54
- readonly autoJoinRefsForFilters: true;
55
- readonly filtersOnRelations: true;
56
- readonly propagationOnPrototype: true;
57
- readonly populateAfterFlush: true;
58
- readonly serialization: {
59
- readonly includePrimaryKeys: true;
60
- };
61
- readonly assign: {
62
- readonly updateNestedEntities: true;
63
- readonly updateByPrimaryKey: true;
64
- readonly mergeObjectProperties: false;
65
- readonly mergeEmbeddedProperties: true;
66
- readonly ignoreUndefined: false;
67
- };
68
- readonly persistOnCreate: true;
69
- readonly upsertManaged: true;
70
- readonly forceEntityConstructor: false;
71
- readonly forceUndefined: false;
72
- readonly forceUtcTimezone: true;
73
- readonly processOnCreateHooksEarly: true;
74
- readonly ensureDatabase: true;
75
- readonly ensureIndexes: false;
76
- readonly batchSize: 300;
77
- readonly debug: false;
78
- readonly ignoreDeprecations: false;
79
- readonly verbose: false;
80
- readonly driverOptions: {};
81
- readonly migrations: {
82
- readonly tableName: "mikro_orm_migrations";
83
- readonly glob: "!(*.d).{js,ts,cjs}";
84
- readonly silent: false;
85
- readonly transactional: true;
86
- readonly allOrNothing: true;
87
- readonly dropTables: true;
88
- readonly safe: false;
89
- readonly snapshot: true;
90
- readonly emit: "ts";
91
- readonly fileName: (timestamp: string, name?: string) => string;
92
- };
93
- readonly schemaGenerator: {
94
- readonly createForeignKeyConstraints: true;
95
- readonly ignoreSchema: readonly [];
96
- readonly skipTables: readonly [];
97
- readonly skipViews: readonly [];
98
- readonly skipColumns: {};
99
- };
100
- readonly embeddables: {
101
- readonly prefixMode: "relative";
102
- };
103
- readonly entityGenerator: {
104
- readonly forceUndefined: true;
105
- readonly undefinedDefaults: false;
106
- readonly scalarTypeInDecorator: false;
107
- readonly bidirectionalRelations: true;
108
- readonly identifiedReferences: true;
109
- readonly scalarPropertiesForRelations: "never";
110
- readonly entityDefinition: "defineEntity";
111
- readonly decorators: "legacy";
112
- readonly enumMode: "dictionary";
113
- readonly fileName: (className: string) => string;
114
- readonly onlyPurePivotTables: false;
115
- readonly outputPurePivotTables: false;
116
- readonly readOnlyPivotTables: false;
117
- readonly useCoreBaseEntity: false;
118
- };
119
- readonly metadataCache: {};
120
- readonly resultCache: {
121
- readonly adapter: typeof MemoryCacheAdapter;
122
- readonly expiration: 1000;
123
- readonly options: {};
124
- };
125
- readonly metadataProvider: typeof MetadataProvider;
126
- readonly highlighter: NullHighlighter;
127
- readonly seeder: {
128
- readonly defaultSeeder: "DatabaseSeeder";
129
- readonly glob: "!(*.d).{js,ts}";
130
- readonly emit: "ts";
131
- readonly fileName: (className: string) => string;
132
- };
133
- readonly preferReadReplicas: true;
134
- readonly dynamicImportProvider: (id: string) => Promise<any>;
135
- };
136
18
  export declare class Configuration<D extends IDatabaseDriver = IDatabaseDriver, EM extends EntityManager<D> = D[typeof EntityManagerType] & EntityManager<D>> {
137
- private readonly options;
138
- private readonly logger;
139
- private readonly driver;
140
- private readonly platform;
141
- private readonly cache;
142
- private readonly extensions;
143
- constructor(options: Options, validate?: boolean);
19
+ #private;
20
+ constructor(options: Partial<Options>, validate?: boolean);
144
21
  getPlatform(): ReturnType<D['getPlatform']>;
145
22
  /**
146
23
  * Gets specific configuration option. Falls back to specified `defaultValue` if provided.
147
24
  */
148
- get<T extends keyof Options<D, EM>, U extends RequiredOptions<D, EM>[T]>(key: T, defaultValue?: U): U;
149
- getAll(): RequiredOptions<D, EM>;
25
+ get<T extends keyof Options<D, EM>, U extends Options<D, EM>[T]>(key: T, defaultValue?: U): U;
26
+ getAll(): Options<D, EM>;
150
27
  /**
151
28
  * Overrides specified configuration value.
152
29
  */
153
- set<T extends keyof Options<D, EM>, U extends RequiredOptions<D, EM>[T]>(key: T, value: U): void;
30
+ set<T extends keyof Options<D, EM>, U extends Options<D, EM>[T]>(key: T, value: U): void;
154
31
  /**
155
32
  * Resets the configuration to its default value
156
33
  */
157
- reset<T extends keyof RequiredOptions<D, EM>>(key: T): void;
34
+ reset<T extends keyof Options<D, EM>>(key: T): void;
158
35
  /**
159
36
  * Gets Logger instance.
160
37
  */
161
38
  getLogger(): Logger;
39
+ /**
40
+ * Gets the logger instance for slow queries.
41
+ * Falls back to the main logger if no custom slow query logger factory is configured.
42
+ */
43
+ getSlowQueryLogger(): Logger;
162
44
  getDataloaderType(): DataloaderType;
163
45
  getSchema(skipDefaultSchema?: boolean): string | undefined;
164
46
  /**
@@ -209,7 +91,7 @@ export declare class Configuration<D extends IDatabaseDriver = IDatabaseDriver,
209
91
  /**
210
92
  * Type helper to make it easier to use `mikro-orm.config.js`.
211
93
  */
212
- export declare function defineConfig<D extends IDatabaseDriver = IDatabaseDriver, EM extends EntityManager<D> = EntityManager<D>, Entities extends (string | EntityClass<AnyEntity> | EntitySchema)[] = (string | EntityClass<AnyEntity> | EntitySchema)[]>(options: Options<D, EM, Entities>): Options<D, EM, Entities>;
94
+ export declare function defineConfig<D extends IDatabaseDriver = IDatabaseDriver, EM extends EntityManager<D> = EntityManager<D>, Entities extends (string | EntityClass<AnyEntity> | EntitySchema)[] = (string | EntityClass<AnyEntity> | EntitySchema)[]>(options: Partial<Options<D, EM, Entities>>): Partial<Options<D, EM, Entities>>;
213
95
  /**
214
96
  * Connection configuration options for database connections.
215
97
  * @see https://mikro-orm.io/docs/configuration#connection
@@ -463,6 +345,13 @@ export interface MetadataDiscoveryOptions {
463
345
  * @see https://mikro-orm.io/docs/configuration
464
346
  */
465
347
  export interface Options<Driver extends IDatabaseDriver = IDatabaseDriver, EM extends EntityManager<Driver> & Driver[typeof EntityManagerType] = EntityManager<Driver> & Driver[typeof EntityManagerType], Entities extends (string | EntityClass<AnyEntity> | EntitySchema)[] = (string | EntityClass<AnyEntity> | EntitySchema)[]> extends ConnectionOptions {
348
+ /** Connection pool configuration. */
349
+ pool: PoolConfig;
350
+ /**
351
+ * Additional driver-specific options.
352
+ * The object will be deeply merged with internal driver options.
353
+ */
354
+ driverOptions: Dictionary;
466
355
  /**
467
356
  * Array of entity classes or paths to entity modules.
468
357
  * Paths support glob patterns for automatic discovery.
@@ -470,7 +359,7 @@ export interface Options<Driver extends IDatabaseDriver = IDatabaseDriver, EM ex
470
359
  * entities: [Author, Book, Publisher] // class references
471
360
  * entities: ['./dist/entities'] // folder paths
472
361
  */
473
- entities?: Entities;
362
+ entities: Entities;
474
363
  /**
475
364
  * Array of TypeScript entity source paths.
476
365
  * Used when running in TypeScript mode (e.g., via `tsx` or `swc`).
@@ -478,34 +367,34 @@ export interface Options<Driver extends IDatabaseDriver = IDatabaseDriver, EM ex
478
367
  * @example
479
368
  * entitiesTs: ['./src/entities']
480
369
  */
481
- entitiesTs?: Entities;
370
+ entitiesTs: Entities;
482
371
  /**
483
372
  * ORM extensions to register (e.g., Migrator, EntityGenerator, SeedManager).
484
373
  * Extensions registered here are available via shortcuts like `orm.migrator`.
485
374
  * @example
486
375
  * extensions: [Migrator, EntityGenerator, SeedManager]
487
376
  */
488
- extensions?: {
377
+ extensions: {
489
378
  register: (orm: MikroORM) => void;
490
379
  }[];
491
380
  /**
492
381
  * Event subscribers to register.
493
382
  * Can be class references or instances.
494
383
  */
495
- subscribers?: Iterable<EventSubscriber | Constructor<EventSubscriber>>;
384
+ subscribers: Iterable<EventSubscriber | Constructor<EventSubscriber>>;
496
385
  /**
497
386
  * Global entity filters to apply.
498
387
  * Filters are applied by default unless explicitly disabled.
499
388
  * @see https://mikro-orm.io/docs/filters
500
389
  */
501
- filters?: Dictionary<{
390
+ filters: Dictionary<{
502
391
  name?: string;
503
392
  } & Omit<FilterDef, 'name'>>;
504
393
  /**
505
394
  * Metadata discovery configuration options.
506
395
  * Controls how entities are discovered and validated.
507
396
  */
508
- discovery?: MetadataDiscoveryOptions;
397
+ discovery: MetadataDiscoveryOptions;
509
398
  /**
510
399
  * Database driver class to use.
511
400
  * Should be imported from the specific driver package (e.g. `@mikro-orm/mysql`, `@mikro-orm/postgresql`).
@@ -545,7 +434,7 @@ export interface Options<Driver extends IDatabaseDriver = IDatabaseDriver, EM ex
545
434
  * Enable verbose logging of internal operations.
546
435
  * @default false
547
436
  */
548
- verbose?: boolean;
437
+ verbose: boolean;
549
438
  /**
550
439
  * Ignore `undefined` values in find queries instead of treating them as `null`.
551
440
  * @default false
@@ -553,7 +442,7 @@ export interface Options<Driver extends IDatabaseDriver = IDatabaseDriver, EM ex
553
442
  * // With ignoreUndefinedInQuery: true
554
443
  * em.find(User, { email: undefined }) // resolves to em.find(User, {})
555
444
  */
556
- ignoreUndefinedInQuery?: boolean;
445
+ ignoreUndefinedInQuery: boolean;
557
446
  /**
558
447
  * Hook to modify SQL queries before execution.
559
448
  * Useful for adding observability hints or query modifications.
@@ -561,38 +450,38 @@ export interface Options<Driver extends IDatabaseDriver = IDatabaseDriver, EM ex
561
450
  * @param params - Query parameters
562
451
  * @returns Modified SQL query
563
452
  */
564
- onQuery?: (sql: string, params: readonly unknown[]) => string;
453
+ onQuery: (sql: string, params: readonly unknown[]) => string;
565
454
  /**
566
455
  * Automatically join the owning side of 1:1 relations when querying the inverse side.
567
456
  * @default true
568
457
  */
569
- autoJoinOneToOneOwner?: boolean;
458
+ autoJoinOneToOneOwner: boolean;
570
459
  /**
571
460
  * Automatically join M:1 and 1:1 relations when filters are defined on them.
572
461
  * Important for implementing soft deletes via filters.
573
462
  * @default true
574
463
  */
575
- autoJoinRefsForFilters?: boolean;
464
+ autoJoinRefsForFilters: boolean;
576
465
  /**
577
466
  * Apply filters to relations in queries.
578
467
  * @default true
579
468
  */
580
- filtersOnRelations?: boolean;
469
+ filtersOnRelations: boolean;
581
470
  /**
582
471
  * Enable propagation of changes on entity prototypes.
583
472
  * @default true
584
473
  */
585
- propagationOnPrototype?: boolean;
474
+ propagationOnPrototype: boolean;
586
475
  /**
587
476
  * Mark all relations as populated after flush for new entities.
588
477
  * This aligns serialized output of loaded entities and just-inserted ones.
589
478
  * @default true
590
479
  */
591
- populateAfterFlush?: boolean;
480
+ populateAfterFlush: boolean;
592
481
  /**
593
482
  * Serialization options for `toJSON()` and `serialize()` methods.
594
483
  */
595
- serialization?: {
484
+ serialization: {
596
485
  /**
597
486
  * Include primary keys in serialized output.
598
487
  * @default true
@@ -609,42 +498,42 @@ export interface Options<Driver extends IDatabaseDriver = IDatabaseDriver, EM ex
609
498
  * Default options for entity assignment via `em.assign()`.
610
499
  * @see https://mikro-orm.io/docs/entity-helper
611
500
  */
612
- assign?: AssignOptions<boolean>;
501
+ assign: AssignOptions<boolean>;
613
502
  /**
614
503
  * Automatically call `em.persist()` on entities created via `em.create()`.
615
504
  * @default true
616
505
  */
617
- persistOnCreate?: boolean;
506
+ persistOnCreate: boolean;
618
507
  /**
619
508
  * When upsert creates a new entity, mark it as managed in the identity map.
620
509
  * @default true
621
510
  */
622
- upsertManaged?: boolean;
511
+ upsertManaged: boolean;
623
512
  /**
624
513
  * Force use of entity constructors when creating entity instances.
625
514
  * Required when using native private properties inside entities.
626
515
  * Can be `true` for all entities or an array of specific entity classes/names.
627
516
  * @default false
628
517
  */
629
- forceEntityConstructor?: boolean | (Constructor<AnyEntity> | string)[];
518
+ forceEntityConstructor: boolean | (Constructor<AnyEntity> | string)[];
630
519
  /**
631
520
  * Convert `null` values from database to `undefined` when hydrating entities.
632
521
  * @default false
633
522
  */
634
- forceUndefined?: boolean;
523
+ forceUndefined: boolean;
635
524
  /**
636
525
  * Property `onCreate` hooks are normally executed during `flush` operation.
637
526
  * With this option, they will be processed early inside `em.create()` method.
638
527
  * @default true
639
528
  */
640
- processOnCreateHooksEarly?: boolean;
529
+ processOnCreateHooksEarly: boolean;
641
530
  /**
642
531
  * Force `Date` values to be stored in UTC for datetime columns without timezone.
643
532
  * Works for MySQL (`datetime` type), PostgreSQL (`timestamp` type), and MSSQL (`datetime`/`datetime2` types).
644
533
  * SQLite does this by default.
645
534
  * @default true
646
535
  */
647
- forceUtcTimezone?: boolean;
536
+ forceUtcTimezone: boolean;
648
537
  /**
649
538
  * Timezone to use for date operations.
650
539
  * @example '+02:00'
@@ -655,13 +544,13 @@ export interface Options<Driver extends IDatabaseDriver = IDatabaseDriver, EM ex
655
544
  * When `true`, will create the database if it doesn't exist.
656
545
  * @default true
657
546
  */
658
- ensureDatabase?: boolean | EnsureDatabaseOptions;
547
+ ensureDatabase: boolean | EnsureDatabaseOptions;
659
548
  /**
660
549
  * Ensure database indexes exist on startup. This option works only with the MongoDB driver.
661
550
  * When enabled, indexes will be created based on entity metadata.
662
551
  * @default false
663
552
  */
664
- ensureIndexes?: boolean;
553
+ ensureIndexes: boolean;
665
554
  /**
666
555
  * Use batch insert queries for better performance.
667
556
  * @default true
@@ -676,12 +565,12 @@ export interface Options<Driver extends IDatabaseDriver = IDatabaseDriver, EM ex
676
565
  * Number of entities to process in each batch for batch inserts/updates.
677
566
  * @default 300
678
567
  */
679
- batchSize?: number;
568
+ batchSize: number;
680
569
  /**
681
570
  * Custom hydrator class for assigning database values to entities.
682
571
  * @default ObjectHydrator
683
572
  */
684
- hydrator?: HydratorConstructor;
573
+ hydrator: HydratorConstructor;
685
574
  /**
686
575
  * Pre-generated compiled functions for hydration and comparison.
687
576
  * Use the `compile` CLI command to create these functions.
@@ -695,7 +584,7 @@ export interface Options<Driver extends IDatabaseDriver = IDatabaseDriver, EM ex
695
584
  * - `'balanced'`: Decides based on relation type and context.
696
585
  * @default 'balanced'
697
586
  */
698
- loadStrategy?: LoadStrategy | `${LoadStrategy}`;
587
+ loadStrategy: LoadStrategy | `${LoadStrategy}`;
699
588
  /**
700
589
  * Enable dataloader for batching reference loading.
701
590
  * - `true` or `DataloaderType.ALL`: Enable for all relation types
@@ -704,14 +593,14 @@ export interface Options<Driver extends IDatabaseDriver = IDatabaseDriver, EM ex
704
593
  * - `DataloaderType.COLLECTION`: Enable only for collections
705
594
  * @default DataloaderType.NONE
706
595
  */
707
- dataloader?: DataloaderType | boolean;
596
+ dataloader: DataloaderType | boolean;
708
597
  /**
709
598
  * Determines how where conditions are applied during population.
710
599
  * - `'all'`: Populate all matching relations (default in v5+)
711
600
  * - `'infer'`: Infer conditions from the original query (v4 behavior)
712
601
  * @default 'all'
713
602
  */
714
- populateWhere?: PopulateHint | `${PopulateHint}`;
603
+ populateWhere: PopulateHint | `${PopulateHint}`;
715
604
  /**
716
605
  * Default flush mode for the entity manager.
717
606
  * - `'commit'`: Flush only on explicit commit
@@ -719,7 +608,7 @@ export interface Options<Driver extends IDatabaseDriver = IDatabaseDriver, EM ex
719
608
  * - `'always'`: Always flush before queries
720
609
  * @default 'auto'
721
610
  */
722
- flushMode?: FlushMode | `${FlushMode}`;
611
+ flushMode: FlushMode | `${FlushMode}`;
723
612
  /**
724
613
  * Custom base repository class for all entities.
725
614
  * Entity-specific repositories can still be defined and will take precedence.
@@ -740,25 +629,25 @@ export interface Options<Driver extends IDatabaseDriver = IDatabaseDriver, EM ex
740
629
  * Validate that required properties are set on new entities before insert.
741
630
  * @default true
742
631
  */
743
- validateRequired?: boolean;
632
+ validateRequired: boolean;
744
633
  /**
745
634
  * Callback to get the current request context's EntityManager.
746
635
  * Used for automatic context propagation in web frameworks.
747
636
  * @default RequestContext.getEntityManager
748
637
  */
749
- context?: (name: string) => EntityManager | undefined;
638
+ context: (name: string) => EntityManager | undefined;
750
639
  /**
751
640
  * Name of the context for multi-ORM setups.
752
641
  * @default 'default'
753
642
  */
754
- contextName?: string;
643
+ contextName: string;
755
644
  /**
756
645
  * Allow using the global EntityManager without a request context.
757
646
  * Not recommended for production - each request should have its own context.
758
647
  * Can also be set via `MIKRO_ORM_ALLOW_GLOBAL_CONTEXT` environment variable.
759
648
  * @default false
760
649
  */
761
- allowGlobalContext?: boolean;
650
+ allowGlobalContext: boolean;
762
651
  /**
763
652
  * When enabled, environment variables take precedence over explicitly provided config options.
764
653
  * By default, explicit options win over env vars.
@@ -776,24 +665,42 @@ export interface Options<Driver extends IDatabaseDriver = IDatabaseDriver, EM ex
776
665
  * Custom logger function for ORM output.
777
666
  * @default console.log
778
667
  */
779
- logger?: (message: string) => void;
668
+ logger: (message: string) => void;
780
669
  /**
781
670
  * Enable colored output in logs.
782
671
  * @default true
783
672
  */
784
- colors?: boolean;
673
+ colors: boolean;
785
674
  /**
786
675
  * Factory function to create a custom logger instance.
787
676
  * @default DefaultLogger.create
788
677
  */
789
678
  loggerFactory?: (options: LoggerOptions) => Logger;
679
+ /**
680
+ * Threshold in milliseconds for logging slow queries.
681
+ * Queries taking at least this long will be logged via the 'slow-query' namespace at warning level.
682
+ * Slow query logs are always emitted when the threshold is met, regardless of the `debug` setting.
683
+ * Set to `0` to log every query as slow.
684
+ * @default undefined (slow query logging disabled)
685
+ */
686
+ slowQueryThreshold?: number;
687
+ /**
688
+ * Factory function to create a custom logger instance for slow queries.
689
+ * Has the same shape as `loggerFactory`. When not provided, the main logger instance is used.
690
+ *
691
+ * Note: slow query log entries are emitted with `context.enabled = true` to bypass the
692
+ * debug-mode check. Custom logger implementations must respect `context.enabled` in their
693
+ * `isEnabled()` method (as `DefaultLogger` does) to ensure slow query logs are always emitted.
694
+ * @default undefined (falls back to main logger)
695
+ */
696
+ slowQueryLoggerFactory?: (options: LoggerOptions) => Logger;
790
697
  /**
791
698
  * Custom error handler for `em.findOneOrFail()` when no entity is found.
792
699
  * @param entityName - Name of the entity being queried
793
700
  * @param where - Query conditions
794
701
  * @returns Error instance to throw
795
702
  */
796
- findOneOrFailHandler?: (entityName: string, where: Dictionary | IPrimaryKey) => Error;
703
+ findOneOrFailHandler: (entityName: string, where: Dictionary | IPrimaryKey) => Error;
797
704
  /**
798
705
  * Custom error handler for `em.findExactlyOneOrFail()` when entity count is not exactly one.
799
706
  * Used when strict mode is enabled.
@@ -801,7 +708,7 @@ export interface Options<Driver extends IDatabaseDriver = IDatabaseDriver, EM ex
801
708
  * @param where - Query conditions
802
709
  * @returns Error instance to throw
803
710
  */
804
- findExactlyOneOrFailHandler?: (entityName: string, where: Dictionary | IPrimaryKey) => Error;
711
+ findExactlyOneOrFailHandler: (entityName: string, where: Dictionary | IPrimaryKey) => Error;
805
712
  /**
806
713
  * Enable debug logging.
807
714
  * Can be `true` for all namespaces or an array of specific namespaces.
@@ -809,19 +716,19 @@ export interface Options<Driver extends IDatabaseDriver = IDatabaseDriver, EM ex
809
716
  * @default false
810
717
  * @see https://mikro-orm.io/docs/logging
811
718
  */
812
- debug?: boolean | LoggerNamespace[];
719
+ debug: boolean | LoggerNamespace[];
813
720
  /**
814
721
  * Ignore deprecation warnings.
815
722
  * Can be `true` to ignore all or an array of specific deprecation labels.
816
723
  * @default false
817
724
  * @see https://mikro-orm.io/docs/logging#deprecation-warnings
818
725
  */
819
- ignoreDeprecations?: boolean | string[];
726
+ ignoreDeprecations: boolean | string[];
820
727
  /**
821
728
  * Syntax highlighter for SQL queries in logs.
822
729
  * @default NullHighlighter
823
730
  */
824
- highlighter?: Highlighter;
731
+ highlighter: Highlighter;
825
732
  /**
826
733
  * Force the ORM to use TypeScript options regardless of detection.
827
734
  * Uses `entitiesTs` for discovery and `pathTs` for migrations/seeders.
@@ -833,16 +740,16 @@ export interface Options<Driver extends IDatabaseDriver = IDatabaseDriver, EM ex
833
740
  * Base directory for resolving relative paths.
834
741
  * @default process.cwd()
835
742
  */
836
- baseDir?: string;
743
+ baseDir: string;
837
744
  /**
838
745
  * Migration configuration options.
839
746
  * @see https://mikro-orm.io/docs/migrations
840
747
  */
841
- migrations?: MigrationsOptions;
748
+ migrations: MigrationsOptions;
842
749
  /**
843
750
  * Schema generator configuration options.
844
751
  */
845
- schemaGenerator?: {
752
+ schemaGenerator: {
846
753
  /**
847
754
  * Try to disable foreign key checks during schema operations.
848
755
  * @default false
@@ -891,11 +798,12 @@ export interface Options<Driver extends IDatabaseDriver = IDatabaseDriver, EM ex
891
798
  * When not set, no rule is emitted and the database uses its native default (NO ACTION/RESTRICT).
892
799
  */
893
800
  defaultDeleteRule?: 'cascade' | 'no action' | 'set null' | 'set default' | 'restrict';
801
+ tableSpace?: string;
894
802
  };
895
803
  /**
896
804
  * Embeddable entity configuration options.
897
805
  */
898
- embeddables?: {
806
+ embeddables: {
899
807
  /**
900
808
  * Mode for generating column prefixes for embedded properties.
901
809
  * @default 'relative'
@@ -906,12 +814,12 @@ export interface Options<Driver extends IDatabaseDriver = IDatabaseDriver, EM ex
906
814
  * Entity generator (code generation) configuration options.
907
815
  * @see https://mikro-orm.io/docs/entity-generator
908
816
  */
909
- entityGenerator?: GenerateOptions;
817
+ entityGenerator: GenerateOptions;
910
818
  /**
911
819
  * Metadata cache configuration for improved startup performance.
912
820
  * @see https://mikro-orm.io/docs/metadata-cache
913
821
  */
914
- metadataCache?: {
822
+ metadataCache: {
915
823
  /**
916
824
  * Enable metadata caching.
917
825
  * Defaults based on the metadata provider's `useCache()` method.
@@ -942,7 +850,7 @@ export interface Options<Driver extends IDatabaseDriver = IDatabaseDriver, EM ex
942
850
  /**
943
851
  * Result cache configuration for query result caching.
944
852
  */
945
- resultCache?: {
853
+ resultCache: {
946
854
  /**
947
855
  * Default cache expiration time in milliseconds.
948
856
  * @default 1000
@@ -972,7 +880,7 @@ export interface Options<Driver extends IDatabaseDriver = IDatabaseDriver, EM ex
972
880
  * @default ReflectMetadataProvider
973
881
  * @see https://mikro-orm.io/docs/metadata-providers
974
882
  */
975
- metadataProvider?: {
883
+ metadataProvider: {
976
884
  new (config: Configuration): MetadataProvider;
977
885
  useCache?: MetadataProvider['useCache'];
978
886
  };
@@ -980,22 +888,15 @@ export interface Options<Driver extends IDatabaseDriver = IDatabaseDriver, EM ex
980
888
  * Seeder configuration options.
981
889
  * @see https://mikro-orm.io/docs/seeding
982
890
  */
983
- seeder?: SeederOptions;
891
+ seeder: SeederOptions;
984
892
  /**
985
893
  * Prefer read replicas for read operations when available.
986
894
  * @default true
987
895
  */
988
- preferReadReplicas?: boolean;
896
+ preferReadReplicas: boolean;
989
897
  /**
990
898
  * Custom dynamic import provider for loading modules.
991
899
  * @default (id) => import(id)
992
900
  */
993
- dynamicImportProvider?: (id: string) => Promise<unknown>;
901
+ dynamicImportProvider: (id: string) => Promise<unknown>;
994
902
  }
995
- type MarkRequired<T, D> = {
996
- [K in keyof T as Extract<K, keyof D>]-?: T[K];
997
- } & {
998
- [K in keyof T as Exclude<K, keyof D>]?: T[K];
999
- };
1000
- export type RequiredOptions<D extends IDatabaseDriver = IDatabaseDriver, EM extends EntityManager<D> = EntityManager<D>, Entities extends (string | EntityClass<AnyEntity> | EntitySchema)[] = (string | EntityClass<AnyEntity> | EntitySchema)[]> = MarkRequired<Options<D, EM, Entities>, typeof DEFAULTS>;
1001
- export {};