@mikro-orm/core 7.0.2-dev.9 → 7.0.2

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 (207) hide show
  1. package/EntityManager.d.ts +883 -579
  2. package/EntityManager.js +1897 -1865
  3. package/MikroORM.d.ts +103 -72
  4. package/MikroORM.js +178 -177
  5. package/README.md +128 -294
  6. package/cache/CacheAdapter.d.ts +38 -36
  7. package/cache/FileCacheAdapter.d.ts +30 -24
  8. package/cache/FileCacheAdapter.js +80 -78
  9. package/cache/GeneratedCacheAdapter.d.ts +19 -20
  10. package/cache/GeneratedCacheAdapter.js +31 -30
  11. package/cache/MemoryCacheAdapter.d.ts +19 -20
  12. package/cache/MemoryCacheAdapter.js +36 -36
  13. package/cache/NullCacheAdapter.d.ts +17 -16
  14. package/cache/NullCacheAdapter.js +25 -24
  15. package/connections/Connection.d.ts +99 -75
  16. package/connections/Connection.js +166 -160
  17. package/drivers/DatabaseDriver.d.ts +187 -69
  18. package/drivers/DatabaseDriver.js +451 -432
  19. package/drivers/IDatabaseDriver.d.ts +464 -281
  20. package/drivers/IDatabaseDriver.js +1 -0
  21. package/entity/BaseEntity.d.ts +121 -73
  22. package/entity/BaseEntity.js +44 -33
  23. package/entity/Collection.d.ts +216 -157
  24. package/entity/Collection.js +728 -707
  25. package/entity/EntityAssigner.d.ts +90 -76
  26. package/entity/EntityAssigner.js +232 -229
  27. package/entity/EntityFactory.d.ts +68 -40
  28. package/entity/EntityFactory.js +427 -366
  29. package/entity/EntityHelper.d.ts +34 -22
  30. package/entity/EntityHelper.js +280 -267
  31. package/entity/EntityIdentifier.d.ts +4 -4
  32. package/entity/EntityIdentifier.js +10 -10
  33. package/entity/EntityLoader.d.ts +105 -56
  34. package/entity/EntityLoader.js +754 -722
  35. package/entity/EntityRepository.d.ts +317 -200
  36. package/entity/EntityRepository.js +214 -212
  37. package/entity/PolymorphicRef.d.ts +5 -5
  38. package/entity/PolymorphicRef.js +10 -10
  39. package/entity/Reference.d.ts +130 -66
  40. package/entity/Reference.js +280 -260
  41. package/entity/WrappedEntity.d.ts +116 -53
  42. package/entity/WrappedEntity.js +169 -147
  43. package/entity/defineEntity.d.ts +1290 -614
  44. package/entity/defineEntity.js +521 -511
  45. package/entity/utils.d.ts +13 -3
  46. package/entity/utils.js +71 -73
  47. package/entity/validators.js +43 -43
  48. package/entity/wrap.js +8 -8
  49. package/enums.d.ts +275 -138
  50. package/enums.js +268 -137
  51. package/errors.d.ts +120 -72
  52. package/errors.js +356 -253
  53. package/events/EventManager.d.ts +27 -10
  54. package/events/EventManager.js +80 -73
  55. package/events/EventSubscriber.d.ts +33 -29
  56. package/events/TransactionEventBroadcaster.d.ts +16 -7
  57. package/events/TransactionEventBroadcaster.js +15 -13
  58. package/exceptions.d.ts +23 -40
  59. package/exceptions.js +35 -52
  60. package/hydration/Hydrator.d.ts +43 -16
  61. package/hydration/Hydrator.js +44 -42
  62. package/hydration/ObjectHydrator.d.ts +51 -17
  63. package/hydration/ObjectHydrator.js +480 -416
  64. package/index.d.ts +116 -2
  65. package/index.js +10 -1
  66. package/logging/DefaultLogger.d.ts +35 -30
  67. package/logging/DefaultLogger.js +87 -84
  68. package/logging/Logger.d.ts +45 -40
  69. package/logging/SimpleLogger.d.ts +13 -11
  70. package/logging/SimpleLogger.js +22 -22
  71. package/logging/colors.d.ts +6 -6
  72. package/logging/colors.js +11 -10
  73. package/logging/inspect.js +7 -7
  74. package/metadata/EntitySchema.d.ts +214 -108
  75. package/metadata/EntitySchema.js +398 -379
  76. package/metadata/MetadataDiscovery.d.ts +115 -111
  77. package/metadata/MetadataDiscovery.js +1948 -1857
  78. package/metadata/MetadataProvider.d.ts +25 -14
  79. package/metadata/MetadataProvider.js +83 -77
  80. package/metadata/MetadataStorage.d.ts +39 -19
  81. package/metadata/MetadataStorage.js +119 -106
  82. package/metadata/MetadataValidator.d.ts +39 -39
  83. package/metadata/MetadataValidator.js +381 -338
  84. package/metadata/discover-entities.d.ts +5 -2
  85. package/metadata/discover-entities.js +27 -27
  86. package/metadata/types.d.ts +615 -531
  87. package/naming-strategy/AbstractNamingStrategy.d.ts +55 -39
  88. package/naming-strategy/AbstractNamingStrategy.js +91 -85
  89. package/naming-strategy/EntityCaseNamingStrategy.d.ts +6 -6
  90. package/naming-strategy/EntityCaseNamingStrategy.js +22 -22
  91. package/naming-strategy/MongoNamingStrategy.d.ts +7 -6
  92. package/naming-strategy/MongoNamingStrategy.js +19 -18
  93. package/naming-strategy/NamingStrategy.d.ts +109 -99
  94. package/naming-strategy/UnderscoreNamingStrategy.d.ts +8 -7
  95. package/naming-strategy/UnderscoreNamingStrategy.js +22 -21
  96. package/not-supported.js +7 -4
  97. package/package.json +1 -1
  98. package/platforms/ExceptionConverter.d.ts +2 -1
  99. package/platforms/ExceptionConverter.js +5 -4
  100. package/platforms/Platform.d.ts +310 -236
  101. package/platforms/Platform.js +661 -573
  102. package/serialization/EntitySerializer.d.ts +49 -25
  103. package/serialization/EntitySerializer.js +224 -216
  104. package/serialization/EntityTransformer.d.ts +11 -5
  105. package/serialization/EntityTransformer.js +220 -216
  106. package/serialization/SerializationContext.d.ts +27 -18
  107. package/serialization/SerializationContext.js +105 -100
  108. package/types/ArrayType.d.ts +9 -8
  109. package/types/ArrayType.js +34 -33
  110. package/types/BigIntType.d.ts +17 -10
  111. package/types/BigIntType.js +37 -37
  112. package/types/BlobType.d.ts +4 -3
  113. package/types/BlobType.js +14 -13
  114. package/types/BooleanType.d.ts +5 -4
  115. package/types/BooleanType.js +13 -12
  116. package/types/CharacterType.d.ts +3 -2
  117. package/types/CharacterType.js +7 -6
  118. package/types/DateTimeType.d.ts +6 -5
  119. package/types/DateTimeType.js +16 -15
  120. package/types/DateType.d.ts +6 -5
  121. package/types/DateType.js +16 -15
  122. package/types/DecimalType.d.ts +7 -7
  123. package/types/DecimalType.js +26 -26
  124. package/types/DoubleType.d.ts +3 -3
  125. package/types/DoubleType.js +12 -12
  126. package/types/EnumArrayType.d.ts +6 -5
  127. package/types/EnumArrayType.js +25 -24
  128. package/types/EnumType.d.ts +4 -3
  129. package/types/EnumType.js +12 -11
  130. package/types/FloatType.d.ts +4 -3
  131. package/types/FloatType.js +10 -9
  132. package/types/IntegerType.d.ts +4 -3
  133. package/types/IntegerType.js +10 -9
  134. package/types/IntervalType.d.ts +5 -4
  135. package/types/IntervalType.js +13 -12
  136. package/types/JsonType.d.ts +9 -8
  137. package/types/JsonType.js +33 -32
  138. package/types/MediumIntType.d.ts +2 -1
  139. package/types/MediumIntType.js +4 -3
  140. package/types/SmallIntType.d.ts +4 -3
  141. package/types/SmallIntType.js +10 -9
  142. package/types/StringType.d.ts +5 -4
  143. package/types/StringType.js +13 -12
  144. package/types/TextType.d.ts +4 -3
  145. package/types/TextType.js +10 -9
  146. package/types/TimeType.d.ts +6 -5
  147. package/types/TimeType.js +18 -17
  148. package/types/TinyIntType.d.ts +4 -3
  149. package/types/TinyIntType.js +11 -10
  150. package/types/Type.d.ts +88 -73
  151. package/types/Type.js +85 -74
  152. package/types/Uint8ArrayType.d.ts +5 -4
  153. package/types/Uint8ArrayType.js +22 -21
  154. package/types/UnknownType.d.ts +5 -4
  155. package/types/UnknownType.js +13 -12
  156. package/types/UuidType.d.ts +6 -5
  157. package/types/UuidType.js +20 -19
  158. package/types/index.d.ts +77 -49
  159. package/types/index.js +64 -26
  160. package/typings.d.ts +1388 -729
  161. package/typings.js +255 -231
  162. package/unit-of-work/ChangeSet.d.ts +28 -24
  163. package/unit-of-work/ChangeSet.js +58 -54
  164. package/unit-of-work/ChangeSetComputer.d.ts +13 -11
  165. package/unit-of-work/ChangeSetComputer.js +180 -159
  166. package/unit-of-work/ChangeSetPersister.d.ts +64 -41
  167. package/unit-of-work/ChangeSetPersister.js +443 -418
  168. package/unit-of-work/CommitOrderCalculator.d.ts +40 -40
  169. package/unit-of-work/CommitOrderCalculator.js +89 -88
  170. package/unit-of-work/IdentityMap.d.ts +32 -25
  171. package/unit-of-work/IdentityMap.js +106 -99
  172. package/unit-of-work/UnitOfWork.d.ts +182 -127
  173. package/unit-of-work/UnitOfWork.js +1201 -1169
  174. package/utils/AbstractMigrator.d.ts +111 -91
  175. package/utils/AbstractMigrator.js +275 -275
  176. package/utils/AbstractSchemaGenerator.d.ts +43 -34
  177. package/utils/AbstractSchemaGenerator.js +121 -122
  178. package/utils/AsyncContext.d.ts +3 -3
  179. package/utils/AsyncContext.js +34 -35
  180. package/utils/Configuration.d.ts +853 -801
  181. package/utils/Configuration.js +360 -337
  182. package/utils/Cursor.d.ts +40 -22
  183. package/utils/Cursor.js +135 -127
  184. package/utils/DataloaderUtils.d.ts +58 -43
  185. package/utils/DataloaderUtils.js +203 -198
  186. package/utils/EntityComparator.d.ts +99 -80
  187. package/utils/EntityComparator.js +825 -727
  188. package/utils/NullHighlighter.d.ts +2 -1
  189. package/utils/NullHighlighter.js +4 -3
  190. package/utils/QueryHelper.d.ts +79 -51
  191. package/utils/QueryHelper.js +372 -361
  192. package/utils/RawQueryFragment.d.ts +54 -28
  193. package/utils/RawQueryFragment.js +110 -99
  194. package/utils/RequestContext.d.ts +33 -32
  195. package/utils/RequestContext.js +52 -53
  196. package/utils/TransactionContext.d.ts +17 -16
  197. package/utils/TransactionContext.js +28 -27
  198. package/utils/TransactionManager.d.ts +58 -58
  199. package/utils/TransactionManager.js +199 -197
  200. package/utils/Utils.d.ts +210 -145
  201. package/utils/Utils.js +820 -813
  202. package/utils/clone.js +104 -113
  203. package/utils/env-vars.js +90 -88
  204. package/utils/fs-utils.d.ts +15 -15
  205. package/utils/fs-utils.js +180 -181
  206. package/utils/upsert-utils.d.ts +20 -5
  207. package/utils/upsert-utils.js +114 -116
@@ -1,7 +1,27 @@
1
1
  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
- import type { AnyEntity, CompiledFunctions, Constructor, Dictionary, EnsureDatabaseOptions, EntityClass, EntityMetadata, FilterDef, GenerateOptions, Highlighter, HydratorConstructor, IHydrator, IMigrationGenerator, IPrimaryKey, MaybePromise, Migration, MigrationObject, Seeder, SeederObject } from '../typings.js';
4
+ import type {
5
+ AnyEntity,
6
+ CompiledFunctions,
7
+ Constructor,
8
+ Dictionary,
9
+ EnsureDatabaseOptions,
10
+ EntityClass,
11
+ EntityMetadata,
12
+ FilterDef,
13
+ GenerateOptions,
14
+ Highlighter,
15
+ HydratorConstructor,
16
+ IHydrator,
17
+ IMigrationGenerator,
18
+ IPrimaryKey,
19
+ MaybePromise,
20
+ Migration,
21
+ MigrationObject,
22
+ Seeder,
23
+ SeederObject,
24
+ } from '../typings.js';
5
25
  import { type Logger, type LoggerNamespace, type LoggerOptions } from '../logging/Logger.js';
6
26
  import type { EntityManager } from '../EntityManager.js';
7
27
  import type { Platform } from '../platforms/Platform.js';
@@ -15,888 +35,920 @@ import { DataloaderType, FlushMode, LoadStrategy, PopulateHint, type EmbeddedPre
15
35
  import { EntityComparator } from './EntityComparator.js';
16
36
  import type { Type } from '../types/Type.js';
17
37
  import type { MikroORM } from '../MikroORM.js';
18
- export declare class Configuration<D extends IDatabaseDriver = IDatabaseDriver, EM extends EntityManager<D> = D[typeof EntityManagerType] & EntityManager<D>> {
19
- #private;
20
- constructor(options: Partial<Options>, validate?: boolean);
21
- getPlatform(): ReturnType<D['getPlatform']>;
22
- /**
23
- * Gets specific configuration option. Falls back to specified `defaultValue` if provided.
24
- */
25
- get<T extends keyof Options<D, EM>, U extends Options<D, EM>[T]>(key: T, defaultValue?: U): U;
26
- getAll(): Options<D, EM>;
27
- /**
28
- * Overrides specified configuration value.
29
- */
30
- set<T extends keyof Options<D, EM>, U extends Options<D, EM>[T]>(key: T, value: U): void;
31
- /**
32
- * Resets the configuration to its default value
33
- */
34
- reset<T extends keyof Options<D, EM>>(key: T): void;
35
- /**
36
- * Gets Logger instance.
37
- */
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;
44
- getDataloaderType(): DataloaderType;
45
- getSchema(skipDefaultSchema?: boolean): string | undefined;
46
- /**
47
- * Gets current database driver instance.
48
- */
49
- getDriver(): D;
50
- registerExtension(name: string, cb: () => unknown): void;
51
- getExtension<T>(name: string): T | undefined;
52
- /**
53
- * Gets instance of NamingStrategy. (cached)
54
- */
55
- getNamingStrategy(): NamingStrategy;
56
- /**
57
- * Gets instance of Hydrator. (cached)
58
- */
59
- getHydrator(metadata: MetadataStorage): IHydrator;
60
- /**
61
- * Gets instance of Comparator. (cached)
62
- */
63
- getComparator(metadata: MetadataStorage): EntityComparator;
64
- /**
65
- * Gets instance of MetadataProvider. (cached)
66
- */
67
- getMetadataProvider(): MetadataProvider;
68
- /**
69
- * Gets instance of metadata CacheAdapter. (cached)
70
- */
71
- getMetadataCacheAdapter(): SyncCacheAdapter;
72
- /**
73
- * Gets instance of CacheAdapter for result cache. (cached)
74
- */
75
- getResultCacheAdapter(): CacheAdapter;
76
- /**
77
- * Gets EntityRepository class to be instantiated.
78
- */
79
- getRepositoryClass(repository: () => EntityClass<EntityRepository<AnyEntity>>): Options<D, EM>['entityRepository'];
80
- /**
81
- * Creates instance of given service and caches it.
82
- */
83
- getCachedService<T extends {
84
- new (...args: any[]): InstanceType<T>;
85
- }>(cls: T, ...args: ConstructorParameters<T>): InstanceType<T>;
86
- resetServiceCache(): void;
87
- private init;
88
- private sync;
89
- private validateOptions;
38
+ /** Holds and validates all ORM configuration options, providing access to drivers, loggers, cache adapters, and other services. */
39
+ export declare class Configuration<
40
+ D extends IDatabaseDriver = IDatabaseDriver,
41
+ EM extends EntityManager<D> = D[typeof EntityManagerType] & EntityManager<D>,
42
+ > {
43
+ #private;
44
+ constructor(options: Partial<Options>, validate?: boolean);
45
+ /** Returns the database platform instance. */
46
+ getPlatform(): ReturnType<D['getPlatform']>;
47
+ /**
48
+ * Gets specific configuration option. Falls back to specified `defaultValue` if provided.
49
+ */
50
+ get<T extends keyof Options<D, EM>, U extends Options<D, EM>[T]>(key: T, defaultValue?: U): U;
51
+ /** Returns all configuration options. */
52
+ getAll(): Options<D, EM>;
53
+ /**
54
+ * Overrides specified configuration value.
55
+ */
56
+ set<T extends keyof Options<D, EM>, U extends Options<D, EM>[T]>(key: T, value: U): void;
57
+ /**
58
+ * Resets the configuration to its default value
59
+ */
60
+ reset<T extends keyof Options<D, EM>>(key: T): void;
61
+ /**
62
+ * Gets Logger instance.
63
+ */
64
+ getLogger(): Logger;
65
+ /**
66
+ * Gets the logger instance for slow queries.
67
+ * Falls back to the main logger if no custom slow query logger factory is configured.
68
+ */
69
+ getSlowQueryLogger(): Logger;
70
+ /** Returns the configured dataloader type, normalizing boolean values. */
71
+ getDataloaderType(): DataloaderType;
72
+ /** Returns the configured schema name, optionally skipping the platform's default schema. */
73
+ getSchema(skipDefaultSchema?: boolean): string | undefined;
74
+ /**
75
+ * Gets current database driver instance.
76
+ */
77
+ getDriver(): D;
78
+ /** Registers a lazily-initialized extension by name. */
79
+ registerExtension(name: string, cb: () => unknown): void;
80
+ /** Returns a previously registered extension by name, initializing it on first access. */
81
+ getExtension<T>(name: string): T | undefined;
82
+ /**
83
+ * Gets instance of NamingStrategy. (cached)
84
+ */
85
+ getNamingStrategy(): NamingStrategy;
86
+ /**
87
+ * Gets instance of Hydrator. (cached)
88
+ */
89
+ getHydrator(metadata: MetadataStorage): IHydrator;
90
+ /**
91
+ * Gets instance of Comparator. (cached)
92
+ */
93
+ getComparator(metadata: MetadataStorage): EntityComparator;
94
+ /**
95
+ * Gets instance of MetadataProvider. (cached)
96
+ */
97
+ getMetadataProvider(): MetadataProvider;
98
+ /**
99
+ * Gets instance of metadata CacheAdapter. (cached)
100
+ */
101
+ getMetadataCacheAdapter(): SyncCacheAdapter;
102
+ /**
103
+ * Gets instance of CacheAdapter for result cache. (cached)
104
+ */
105
+ getResultCacheAdapter(): CacheAdapter;
106
+ /**
107
+ * Gets EntityRepository class to be instantiated.
108
+ */
109
+ getRepositoryClass(repository: () => EntityClass<EntityRepository<AnyEntity>>): Options<D, EM>['entityRepository'];
110
+ /**
111
+ * Creates instance of given service and caches it.
112
+ */
113
+ getCachedService<
114
+ T extends {
115
+ new (...args: any[]): InstanceType<T>;
116
+ },
117
+ >(cls: T, ...args: ConstructorParameters<T>): InstanceType<T>;
118
+ /** Clears the cached service instances, forcing re-creation on next access. */
119
+ resetServiceCache(): void;
120
+ private init;
121
+ private sync;
122
+ private validateOptions;
90
123
  }
91
124
  /**
92
125
  * Type helper to make it easier to use `mikro-orm.config.js`.
93
126
  */
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>>;
127
+ export declare function defineConfig<
128
+ D extends IDatabaseDriver = IDatabaseDriver,
129
+ EM extends EntityManager<D> = EntityManager<D>,
130
+ Entities extends (string | EntityClass<AnyEntity> | EntitySchema)[] = (
131
+ | string
132
+ | EntityClass<AnyEntity>
133
+ | EntitySchema
134
+ )[],
135
+ >(options: Partial<Options<D, EM, Entities>>): Partial<Options<D, EM, Entities>>;
95
136
  /**
96
137
  * Connection configuration options for database connections.
97
138
  * @see https://mikro-orm.io/docs/configuration#connection
98
139
  */
99
140
  export interface ConnectionOptions {
100
- /** Name of the database to connect to. */
101
- dbName?: string;
102
- /** Default database schema to use. */
103
- schema?: string;
104
- /** Name of the connection (used for logging when replicas are used). */
105
- name?: string;
106
- /** Full client connection URL. Overrides individual connection options. */
107
- clientUrl?: string;
108
- /** Database server hostname. */
109
- host?: string;
110
- /** Database server port number. */
111
- port?: number;
112
- /** Database user name. */
113
- user?: string;
114
- /**
115
- * Database password. Can be a string or a callback function that returns the password.
116
- * The callback is useful for short-lived tokens from cloud providers.
117
- * @example
118
- * password: async () => someCallToGetTheToken()
119
- */
120
- password?: string | (() => MaybePromise<string>);
121
- /** Character set for the connection. */
122
- charset?: string;
123
- /** Collation for the connection. */
124
- collate?: string;
125
- /**
126
- * Enable multiple statements in a single query.
127
- * Required for importing database dump files.
128
- * Should be disabled in production for security.
129
- * @default false
130
- */
131
- multipleStatements?: boolean;
132
- /** Connection pool configuration. */
133
- pool?: PoolConfig;
134
- /**
135
- * Additional driver-specific options.
136
- * The object will be deeply merged with internal driver options.
137
- */
138
- driverOptions?: Dictionary;
139
- /** Callback to execute when a new connection is created. */
140
- onCreateConnection?: (connection: unknown) => Promise<void>;
141
- /**
142
- * SQLite/libSQL: databases to attach on connection.
143
- * Each attached database acts as a schema, accessible via `schema.table` syntax.
144
- * Entities can reference attached databases via `@Entity({ schema: 'db_name' })`.
145
- * Note: Not supported for remote libSQL connections.
146
- * @example
147
- * attachDatabases: [
148
- * { name: 'users_db', path: './users.db' },
149
- * { name: 'logs_db', path: '/var/data/logs.db' },
150
- * ]
151
- */
152
- attachDatabases?: {
153
- name: string;
154
- path: string;
155
- }[];
141
+ /** Name of the database to connect to. */
142
+ dbName?: string;
143
+ /** Default database schema to use. */
144
+ schema?: string;
145
+ /** Name of the connection (used for logging when replicas are used). */
146
+ name?: string;
147
+ /** Full client connection URL. Overrides individual connection options. */
148
+ clientUrl?: string;
149
+ /** Database server hostname. */
150
+ host?: string;
151
+ /** Database server port number. */
152
+ port?: number;
153
+ /** Database user name. */
154
+ user?: string;
155
+ /**
156
+ * Database password. Can be a string or a callback function that returns the password.
157
+ * The callback is useful for short-lived tokens from cloud providers.
158
+ * @example
159
+ * password: async () => someCallToGetTheToken()
160
+ */
161
+ password?: string | (() => MaybePromise<string>);
162
+ /** Character set for the connection. */
163
+ charset?: string;
164
+ /** Collation for the connection. */
165
+ collate?: string;
166
+ /**
167
+ * Enable multiple statements in a single query.
168
+ * Required for importing database dump files.
169
+ * Should be disabled in production for security.
170
+ * @default false
171
+ */
172
+ multipleStatements?: boolean;
173
+ /** Connection pool configuration. */
174
+ pool?: PoolConfig;
175
+ /**
176
+ * Additional driver-specific options.
177
+ * The object will be deeply merged with internal driver options.
178
+ */
179
+ driverOptions?: Dictionary;
180
+ /** Callback to execute when a new connection is created. */
181
+ onCreateConnection?: (connection: unknown) => Promise<void>;
182
+ /**
183
+ * SQLite/libSQL: databases to attach on connection.
184
+ * Each attached database acts as a schema, accessible via `schema.table` syntax.
185
+ * Entities can reference attached databases via `@Entity({ schema: 'db_name' })`.
186
+ * Note: Not supported for remote libSQL connections.
187
+ * @example
188
+ * attachDatabases: [
189
+ * { name: 'users_db', path: './users.db' },
190
+ * { name: 'logs_db', path: '/var/data/logs.db' },
191
+ * ]
192
+ */
193
+ attachDatabases?: {
194
+ name: string;
195
+ path: string;
196
+ }[];
156
197
  }
157
198
  /**
158
199
  * Configuration options for database migrations.
159
200
  * @see https://mikro-orm.io/docs/migrations
160
201
  */
161
202
  export type MigrationsOptions = {
162
- /**
163
- * Name of the migrations table.
164
- * @default 'mikro_orm_migrations'
165
- */
166
- tableName?: string;
167
- /**
168
- * Path to the folder with migration files (for compiled JavaScript files).
169
- * @default './migrations'
170
- */
171
- path?: string;
172
- /**
173
- * Path to the folder with migration files (for TypeScript source files).
174
- * Used when running in TypeScript mode.
175
- */
176
- pathTs?: string;
177
- /**
178
- * Glob pattern to match migration files.
179
- * @default '!(*.d).{js,ts,cjs}'
180
- */
181
- glob?: string;
182
- /**
183
- * Disable logging for migration operations.
184
- * @default false
185
- */
186
- silent?: boolean;
187
- /**
188
- * Run each migration inside a transaction.
189
- * @default true
190
- */
191
- transactional?: boolean;
192
- /**
193
- * Try to disable foreign key checks during migrations.
194
- * @default false
195
- */
196
- disableForeignKeys?: boolean;
197
- /**
198
- * Run all migrations in the current batch in a master transaction.
199
- * @default true
200
- */
201
- allOrNothing?: boolean;
202
- /**
203
- * Allow dropping tables during schema diff.
204
- * @default true
205
- */
206
- dropTables?: boolean;
207
- /**
208
- * Safe mode - only allow adding new tables and columns, never dropping existing ones.
209
- * @default false
210
- */
211
- safe?: boolean;
212
- /**
213
- * Create a snapshot of the current schema after migration generation.
214
- * @default true
215
- */
216
- snapshot?: boolean;
217
- /** Custom name for the snapshot file. */
218
- snapshotName?: string;
219
- /**
220
- * File extension for generated migration files.
221
- * @default 'ts'
222
- */
223
- emit?: 'js' | 'ts' | 'cjs';
224
- /** Custom migration generator class. */
225
- generator?: Constructor<IMigrationGenerator>;
226
- /**
227
- * Custom function to generate migration file names.
228
- * @default (timestamp, name) => `Migration${timestamp}${name ? '_' + name : ''}`
229
- */
230
- fileName?: (timestamp: string, name?: string) => string;
231
- /** List of migration classes or objects to use instead of file-based discovery. */
232
- migrationsList?: (MigrationObject | Constructor<Migration>)[];
203
+ /**
204
+ * Name of the migrations table.
205
+ * @default 'mikro_orm_migrations'
206
+ */
207
+ tableName?: string;
208
+ /**
209
+ * Path to the folder with migration files (for compiled JavaScript files).
210
+ * @default './migrations'
211
+ */
212
+ path?: string;
213
+ /**
214
+ * Path to the folder with migration files (for TypeScript source files).
215
+ * Used when running in TypeScript mode.
216
+ */
217
+ pathTs?: string;
218
+ /**
219
+ * Glob pattern to match migration files.
220
+ * @default '!(*.d).{js,ts,cjs}'
221
+ */
222
+ glob?: string;
223
+ /**
224
+ * Disable logging for migration operations.
225
+ * @default false
226
+ */
227
+ silent?: boolean;
228
+ /**
229
+ * Run each migration inside a transaction.
230
+ * @default true
231
+ */
232
+ transactional?: boolean;
233
+ /**
234
+ * Try to disable foreign key checks during migrations.
235
+ * @default false
236
+ */
237
+ disableForeignKeys?: boolean;
238
+ /**
239
+ * Run all migrations in the current batch in a master transaction.
240
+ * @default true
241
+ */
242
+ allOrNothing?: boolean;
243
+ /**
244
+ * Allow dropping tables during schema diff.
245
+ * @default true
246
+ */
247
+ dropTables?: boolean;
248
+ /**
249
+ * Safe mode - only allow adding new tables and columns, never dropping existing ones.
250
+ * @default false
251
+ */
252
+ safe?: boolean;
253
+ /**
254
+ * Create a snapshot of the current schema after migration generation.
255
+ * @default true
256
+ */
257
+ snapshot?: boolean;
258
+ /** Custom name for the snapshot file. */
259
+ snapshotName?: string;
260
+ /**
261
+ * File extension for generated migration files.
262
+ * @default 'ts'
263
+ */
264
+ emit?: 'js' | 'ts' | 'cjs';
265
+ /** Custom migration generator class. */
266
+ generator?: Constructor<IMigrationGenerator>;
267
+ /**
268
+ * Custom function to generate migration file names.
269
+ * @default (timestamp, name) => `Migration${timestamp}${name ? '_' + name : ''}`
270
+ */
271
+ fileName?: (timestamp: string, name?: string) => string;
272
+ /** List of migration classes or objects to use instead of file-based discovery. */
273
+ migrationsList?: (MigrationObject | Constructor<Migration>)[];
233
274
  };
234
275
  /**
235
276
  * Configuration options for database seeders.
236
277
  * @see https://mikro-orm.io/docs/seeding
237
278
  */
238
279
  export interface SeederOptions {
239
- /**
240
- * Path to the folder with seeder files (for compiled JavaScript files).
241
- * @default './seeders'
242
- */
243
- path?: string;
244
- /**
245
- * Path to the folder with seeder files (for TypeScript source files).
246
- * Used when running in TypeScript mode.
247
- */
248
- pathTs?: string;
249
- /**
250
- * Glob pattern to match seeder files.
251
- * @default '!(*.d).{js,ts}'
252
- */
253
- glob?: string;
254
- /**
255
- * Name of the default seeder class to run.
256
- * @default 'DatabaseSeeder'
257
- */
258
- defaultSeeder?: string;
259
- /**
260
- * File extension for generated seeder files.
261
- * @default 'ts'
262
- */
263
- emit?: 'js' | 'ts';
264
- /**
265
- * Custom function to generate seeder file names.
266
- * @default (className) => className
267
- */
268
- fileName?: (className: string) => string;
269
- /** List of seeder classes or objects to use instead of file-based discovery. */
270
- seedersList?: (SeederObject | Constructor<Seeder>)[];
280
+ /**
281
+ * Path to the folder with seeder files (for compiled JavaScript files).
282
+ * @default './seeders'
283
+ */
284
+ path?: string;
285
+ /**
286
+ * Path to the folder with seeder files (for TypeScript source files).
287
+ * Used when running in TypeScript mode.
288
+ */
289
+ pathTs?: string;
290
+ /**
291
+ * Glob pattern to match seeder files.
292
+ * @default '!(*.d).{js,ts}'
293
+ */
294
+ glob?: string;
295
+ /**
296
+ * Name of the default seeder class to run.
297
+ * @default 'DatabaseSeeder'
298
+ */
299
+ defaultSeeder?: string;
300
+ /**
301
+ * File extension for generated seeder files.
302
+ * @default 'ts'
303
+ */
304
+ emit?: 'js' | 'ts';
305
+ /**
306
+ * Custom function to generate seeder file names.
307
+ * @default (className) => className
308
+ */
309
+ fileName?: (className: string) => string;
310
+ /** List of seeder classes or objects to use instead of file-based discovery. */
311
+ seedersList?: (SeederObject | Constructor<Seeder>)[];
271
312
  }
272
313
  /**
273
314
  * Connection pool configuration.
274
315
  * @see https://mikro-orm.io/docs/configuration#connection
275
316
  */
276
317
  export interface PoolConfig {
277
- /** Minimum number of connections to keep in the pool. */
278
- min?: number;
279
- /** Maximum number of connections allowed in the pool. */
280
- max?: number;
281
- /** Time in milliseconds before an idle connection is closed. */
282
- idleTimeoutMillis?: number;
318
+ /** Minimum number of connections to keep in the pool. */
319
+ min?: number;
320
+ /** Maximum number of connections allowed in the pool. */
321
+ max?: number;
322
+ /** Time in milliseconds before an idle connection is closed. */
323
+ idleTimeoutMillis?: number;
283
324
  }
284
325
  /**
285
326
  * Configuration options for metadata discovery.
286
327
  * @see https://mikro-orm.io/docs/configuration#entity-discovery
287
328
  */
288
329
  export interface MetadataDiscoveryOptions {
289
- /**
290
- * Throw an error when no entities are discovered.
291
- * @default true
292
- */
293
- warnWhenNoEntities?: boolean;
294
- /**
295
- * Check for duplicate table names and throw an error if found.
296
- * @default true
297
- */
298
- checkDuplicateTableNames?: boolean;
299
- /**
300
- * Check for duplicate field names and throw an error if found.
301
- * @default true
302
- */
303
- checkDuplicateFieldNames?: boolean;
304
- /**
305
- * Check for composite primary keys marked as `persist: false` and throw an error if found.
306
- * @default true
307
- */
308
- checkNonPersistentCompositeProps?: boolean;
309
- /**
310
- * Infer default values from property initializers when possible
311
- * (if the constructor can be invoked without parameters).
312
- * @default true
313
- */
314
- inferDefaultValues?: boolean;
315
- /**
316
- * Custom callback to override default type mapping.
317
- * Allows customizing how property types are mapped to database column types.
318
- * @example
319
- * getMappedType(type, platform) {
320
- * if (type === 'string') {
321
- * return Type.getType(TextType);
322
- * }
323
- * return platform.getDefaultMappedType(type);
324
- * }
325
- */
326
- getMappedType?: (type: string, platform: Platform) => Type<unknown> | undefined;
327
- /**
328
- * Hook called for each entity metadata during discovery.
329
- * Can be used to modify metadata dynamically before defaults are filled in.
330
- * The hook can be async when using `MikroORM.init()`.
331
- */
332
- onMetadata?: (meta: EntityMetadata, platform: Platform) => MaybePromise<void>;
333
- /**
334
- * Hook called after all entities are discovered.
335
- * Can be used to access and modify all metadata at once.
336
- */
337
- afterDiscovered?: (storage: MetadataStorage, platform: Platform) => MaybePromise<void>;
338
- /** Path to the TypeScript configuration file for ts-morph metadata provider. */
339
- tsConfigPath?: string;
340
- /** @internal */
341
- skipSyncDiscovery?: boolean;
330
+ /**
331
+ * Throw an error when no entities are discovered.
332
+ * @default true
333
+ */
334
+ warnWhenNoEntities?: boolean;
335
+ /**
336
+ * Check for duplicate table names and throw an error if found.
337
+ * @default true
338
+ */
339
+ checkDuplicateTableNames?: boolean;
340
+ /**
341
+ * Check for duplicate field names and throw an error if found.
342
+ * @default true
343
+ */
344
+ checkDuplicateFieldNames?: boolean;
345
+ /**
346
+ * Check for composite primary keys marked as `persist: false` and throw an error if found.
347
+ * @default true
348
+ */
349
+ checkNonPersistentCompositeProps?: boolean;
350
+ /**
351
+ * Infer default values from property initializers when possible
352
+ * (if the constructor can be invoked without parameters).
353
+ * @default true
354
+ */
355
+ inferDefaultValues?: boolean;
356
+ /**
357
+ * Custom callback to override default type mapping.
358
+ * Allows customizing how property types are mapped to database column types.
359
+ * @example
360
+ * getMappedType(type, platform) {
361
+ * if (type === 'string') {
362
+ * return Type.getType(TextType);
363
+ * }
364
+ * return platform.getDefaultMappedType(type);
365
+ * }
366
+ */
367
+ getMappedType?: (type: string, platform: Platform) => Type<unknown> | undefined;
368
+ /**
369
+ * Hook called for each entity metadata during discovery.
370
+ * Can be used to modify metadata dynamically before defaults are filled in.
371
+ * The hook can be async when using `MikroORM.init()`.
372
+ */
373
+ onMetadata?: (meta: EntityMetadata, platform: Platform) => MaybePromise<void>;
374
+ /**
375
+ * Hook called after all entities are discovered.
376
+ * Can be used to access and modify all metadata at once.
377
+ */
378
+ afterDiscovered?: (storage: MetadataStorage, platform: Platform) => MaybePromise<void>;
379
+ /** Path to the TypeScript configuration file for ts-morph metadata provider. */
380
+ tsConfigPath?: string;
381
+ /** @internal */
382
+ skipSyncDiscovery?: boolean;
342
383
  }
343
384
  /**
344
385
  * MikroORM configuration options.
345
386
  * @see https://mikro-orm.io/docs/configuration
346
387
  */
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;
355
- /**
356
- * Array of entity classes or paths to entity modules.
357
- * Paths support glob patterns for automatic discovery.
358
- * @example
359
- * entities: [Author, Book, Publisher] // class references
360
- * entities: ['./dist/entities'] // folder paths
361
- */
362
- entities: Entities;
363
- /**
364
- * Array of TypeScript entity source paths.
365
- * Used when running in TypeScript mode (e.g., via `tsx` or `swc`).
366
- * Should always be specified when using folder-based discovery.
367
- * @example
368
- * entitiesTs: ['./src/entities']
369
- */
370
- entitiesTs: Entities;
371
- /**
372
- * ORM extensions to register (e.g., Migrator, EntityGenerator, SeedManager).
373
- * Extensions registered here are available via shortcuts like `orm.migrator`.
374
- * @example
375
- * extensions: [Migrator, EntityGenerator, SeedManager]
376
- */
377
- extensions: {
378
- register: (orm: MikroORM) => void;
379
- }[];
380
- /**
381
- * Event subscribers to register.
382
- * Can be class references or instances.
383
- */
384
- subscribers: Iterable<EventSubscriber | Constructor<EventSubscriber>>;
385
- /**
386
- * Global entity filters to apply.
387
- * Filters are applied by default unless explicitly disabled.
388
- * @see https://mikro-orm.io/docs/filters
389
- */
390
- filters: Dictionary<{
391
- name?: string;
392
- } & Omit<FilterDef, 'name'>>;
393
- /**
394
- * Metadata discovery configuration options.
395
- * Controls how entities are discovered and validated.
396
- */
397
- discovery: MetadataDiscoveryOptions;
398
- /**
399
- * Database driver class to use.
400
- * Should be imported from the specific driver package (e.g. `@mikro-orm/mysql`, `@mikro-orm/postgresql`).
401
- * Alternatively, use the `defineConfig` helper or `MikroORM` class exported from the driver package.
402
- * @example
403
- * import { MySqlDriver } from '@mikro-orm/mysql';
404
- *
405
- * MikroORM.init({
406
- * driver: MySqlDriver,
407
- * dbName: 'my_db',
408
- * });
409
- */
410
- driver?: {
411
- new (config: Configuration): Driver;
412
- };
413
- /**
414
- * Custom naming strategy class for mapping entity/property names to database table/column names.
415
- * Built-in options: `UnderscoreNamingStrategy`, `MongoNamingStrategy`, `EntityCaseNamingStrategy`.
416
- * @see https://mikro-orm.io/docs/naming-strategy
417
- */
418
- namingStrategy?: {
419
- new (): NamingStrategy;
420
- };
421
- /**
422
- * Enable implicit transactions for all write operations.
423
- * When enabled, all queries will be wrapped in a transaction.
424
- * Disabled for MongoDB driver by default.
425
- */
426
- implicitTransactions?: boolean;
427
- /**
428
- * Disable all transactions.
429
- * When enabled, no queries will be wrapped in transactions, even when explicitly requested.
430
- * @default false
431
- */
432
- disableTransactions?: boolean;
433
- /**
434
- * Enable verbose logging of internal operations.
435
- * @default false
436
- */
437
- verbose: boolean;
438
- /**
439
- * Ignore `undefined` values in find queries instead of treating them as `null`.
440
- * @default false
441
- * @example
442
- * // With ignoreUndefinedInQuery: true
443
- * em.find(User, { email: undefined }) // resolves to em.find(User, {})
444
- */
445
- ignoreUndefinedInQuery: boolean;
446
- /**
447
- * Hook to modify SQL queries before execution.
448
- * Useful for adding observability hints or query modifications.
449
- * @param sql - The generated SQL query
450
- * @param params - Query parameters
451
- * @returns Modified SQL query
452
- */
453
- onQuery: (sql: string, params: readonly unknown[]) => string;
454
- /**
455
- * Automatically join the owning side of 1:1 relations when querying the inverse side.
456
- * @default true
457
- */
458
- autoJoinOneToOneOwner: boolean;
459
- /**
460
- * Automatically join M:1 and 1:1 relations when filters are defined on them.
461
- * Important for implementing soft deletes via filters.
462
- * @default true
463
- */
464
- autoJoinRefsForFilters: boolean;
465
- /**
466
- * Apply filters to relations in queries.
467
- * @default true
468
- */
469
- filtersOnRelations: boolean;
470
- /**
471
- * Enable propagation of changes on entity prototypes.
388
+ export interface Options<
389
+ Driver extends IDatabaseDriver = IDatabaseDriver,
390
+ EM extends EntityManager<Driver> & Driver[typeof EntityManagerType] = EntityManager<Driver> &
391
+ Driver[typeof EntityManagerType],
392
+ Entities extends (string | EntityClass<AnyEntity> | EntitySchema)[] = (
393
+ | string
394
+ | EntityClass<AnyEntity>
395
+ | EntitySchema
396
+ )[],
397
+ > extends ConnectionOptions {
398
+ /** Connection pool configuration. */
399
+ pool: PoolConfig;
400
+ /**
401
+ * Additional driver-specific options.
402
+ * The object will be deeply merged with internal driver options.
403
+ */
404
+ driverOptions: Dictionary;
405
+ /**
406
+ * Array of entity classes or paths to entity modules.
407
+ * Paths support glob patterns for automatic discovery.
408
+ * @example
409
+ * entities: [Author, Book, Publisher] // class references
410
+ * entities: ['./dist/entities'] // folder paths
411
+ */
412
+ entities: Entities;
413
+ /**
414
+ * Array of TypeScript entity source paths.
415
+ * Used when running in TypeScript mode (e.g., via `tsx` or `swc`).
416
+ * Should always be specified when using folder-based discovery.
417
+ * @example
418
+ * entitiesTs: ['./src/entities']
419
+ */
420
+ entitiesTs: Entities;
421
+ /**
422
+ * ORM extensions to register (e.g., Migrator, EntityGenerator, SeedManager).
423
+ * Extensions registered here are available via shortcuts like `orm.migrator`.
424
+ * @example
425
+ * extensions: [Migrator, EntityGenerator, SeedManager]
426
+ */
427
+ extensions: {
428
+ register: (orm: MikroORM) => void;
429
+ }[];
430
+ /**
431
+ * Event subscribers to register.
432
+ * Can be class references or instances.
433
+ */
434
+ subscribers: Iterable<EventSubscriber | Constructor<EventSubscriber>>;
435
+ /**
436
+ * Global entity filters to apply.
437
+ * Filters are applied by default unless explicitly disabled.
438
+ * @see https://mikro-orm.io/docs/filters
439
+ */
440
+ filters: Dictionary<
441
+ {
442
+ name?: string;
443
+ } & Omit<FilterDef, 'name'>
444
+ >;
445
+ /**
446
+ * Metadata discovery configuration options.
447
+ * Controls how entities are discovered and validated.
448
+ */
449
+ discovery: MetadataDiscoveryOptions;
450
+ /**
451
+ * Database driver class to use.
452
+ * Should be imported from the specific driver package (e.g. `@mikro-orm/mysql`, `@mikro-orm/postgresql`).
453
+ * Alternatively, use the `defineConfig` helper or `MikroORM` class exported from the driver package.
454
+ * @example
455
+ * import { MySqlDriver } from '@mikro-orm/mysql';
456
+ *
457
+ * MikroORM.init({
458
+ * driver: MySqlDriver,
459
+ * dbName: 'my_db',
460
+ * });
461
+ */
462
+ driver?: {
463
+ new (config: Configuration): Driver;
464
+ };
465
+ /**
466
+ * Custom naming strategy class for mapping entity/property names to database table/column names.
467
+ * Built-in options: `UnderscoreNamingStrategy`, `MongoNamingStrategy`, `EntityCaseNamingStrategy`.
468
+ * @see https://mikro-orm.io/docs/naming-strategy
469
+ */
470
+ namingStrategy?: {
471
+ new (): NamingStrategy;
472
+ };
473
+ /**
474
+ * Enable implicit transactions for all write operations.
475
+ * When enabled, all queries will be wrapped in a transaction.
476
+ * Disabled for MongoDB driver by default.
477
+ */
478
+ implicitTransactions?: boolean;
479
+ /**
480
+ * Disable all transactions.
481
+ * When enabled, no queries will be wrapped in transactions, even when explicitly requested.
482
+ * @default false
483
+ */
484
+ disableTransactions?: boolean;
485
+ /**
486
+ * Enable verbose logging of internal operations.
487
+ * @default false
488
+ */
489
+ verbose: boolean;
490
+ /**
491
+ * Ignore `undefined` values in find queries instead of treating them as `null`.
492
+ * @default false
493
+ * @example
494
+ * // With ignoreUndefinedInQuery: true
495
+ * em.find(User, { email: undefined }) // resolves to em.find(User, {})
496
+ */
497
+ ignoreUndefinedInQuery: boolean;
498
+ /**
499
+ * Hook to modify SQL queries before execution.
500
+ * Useful for adding observability hints or query modifications.
501
+ * @param sql - The generated SQL query
502
+ * @param params - Query parameters
503
+ * @returns Modified SQL query
504
+ */
505
+ onQuery: (sql: string, params: readonly unknown[]) => string;
506
+ /**
507
+ * Automatically join the owning side of 1:1 relations when querying the inverse side.
508
+ * @default true
509
+ */
510
+ autoJoinOneToOneOwner: boolean;
511
+ /**
512
+ * Automatically join M:1 and 1:1 relations when filters are defined on them.
513
+ * Important for implementing soft deletes via filters.
514
+ * @default true
515
+ */
516
+ autoJoinRefsForFilters: boolean;
517
+ /**
518
+ * Apply filters to relations in queries.
519
+ * @default true
520
+ */
521
+ filtersOnRelations: boolean;
522
+ /**
523
+ * Enable propagation of changes on entity prototypes.
524
+ * @default true
525
+ */
526
+ propagationOnPrototype: boolean;
527
+ /**
528
+ * Mark all relations as populated after flush for new entities.
529
+ * This aligns serialized output of loaded entities and just-inserted ones.
530
+ * @default true
531
+ */
532
+ populateAfterFlush: boolean;
533
+ /**
534
+ * Serialization options for `toJSON()` and `serialize()` methods.
535
+ */
536
+ serialization: {
537
+ /**
538
+ * Include primary keys in serialized output.
472
539
  * @default true
473
540
  */
474
- propagationOnPrototype: boolean;
541
+ includePrimaryKeys?: boolean;
475
542
  /**
476
- * Mark all relations as populated after flush for new entities.
477
- * This aligns serialized output of loaded entities and just-inserted ones.
478
- * @default true
479
- */
480
- populateAfterFlush: boolean;
481
- /**
482
- * Serialization options for `toJSON()` and `serialize()` methods.
483
- */
484
- serialization: {
485
- /**
486
- * Include primary keys in serialized output.
487
- * @default true
488
- */
489
- includePrimaryKeys?: boolean;
490
- /**
491
- * Enforce unpopulated references to be returned as objects.
492
- * When enabled, references are serialized as `{ author: { id: 1 } }` instead of `{ author: 1 }`.
493
- * @default false
494
- */
495
- forceObject?: boolean;
496
- };
497
- /**
498
- * Default options for entity assignment via `em.assign()`.
499
- * @see https://mikro-orm.io/docs/entity-helper
500
- */
501
- assign: AssignOptions<boolean>;
502
- /**
503
- * Automatically call `em.persist()` on entities created via `em.create()`.
504
- * @default true
505
- */
506
- persistOnCreate: boolean;
507
- /**
508
- * When upsert creates a new entity, mark it as managed in the identity map.
509
- * @default true
510
- */
511
- upsertManaged: boolean;
512
- /**
513
- * Force use of entity constructors when creating entity instances.
514
- * Required when using native private properties inside entities.
515
- * Can be `true` for all entities or an array of specific entity classes/names.
543
+ * Enforce unpopulated references to be returned as objects.
544
+ * When enabled, references are serialized as `{ author: { id: 1 } }` instead of `{ author: 1 }`.
516
545
  * @default false
517
546
  */
518
- forceEntityConstructor: boolean | (Constructor<AnyEntity> | string)[];
519
- /**
520
- * Convert `null` values from database to `undefined` when hydrating entities.
521
- * @default false
522
- */
523
- forceUndefined: boolean;
524
- /**
525
- * Property `onCreate` hooks are normally executed during `flush` operation.
526
- * With this option, they will be processed early inside `em.create()` method.
527
- * @default true
528
- */
529
- processOnCreateHooksEarly: boolean;
530
- /**
531
- * Force `Date` values to be stored in UTC for datetime columns without timezone.
532
- * Works for MySQL (`datetime` type), PostgreSQL (`timestamp` type), and MSSQL (`datetime`/`datetime2` types).
533
- * SQLite does this by default.
534
- * @default true
535
- */
536
- forceUtcTimezone: boolean;
537
- /**
538
- * Timezone to use for date operations.
539
- * @example '+02:00'
540
- */
541
- timezone?: string;
542
- /**
543
- * Ensure the database exists when initializing the ORM.
544
- * When `true`, will create the database if it doesn't exist.
545
- * @default true
546
- */
547
- ensureDatabase: boolean | EnsureDatabaseOptions;
548
- /**
549
- * Ensure database indexes exist on startup. This option works only with the MongoDB driver.
550
- * When enabled, indexes will be created based on entity metadata.
547
+ forceObject?: boolean;
548
+ };
549
+ /**
550
+ * Default options for entity assignment via `em.assign()`.
551
+ * @see https://mikro-orm.io/docs/entity-helper
552
+ */
553
+ assign: AssignOptions<boolean>;
554
+ /**
555
+ * Automatically call `em.persist()` on entities created via `em.create()`.
556
+ * @default true
557
+ */
558
+ persistOnCreate: boolean;
559
+ /**
560
+ * When upsert creates a new entity, mark it as managed in the identity map.
561
+ * @default true
562
+ */
563
+ upsertManaged: boolean;
564
+ /**
565
+ * Force use of entity constructors when creating entity instances.
566
+ * Required when using native private properties inside entities.
567
+ * Can be `true` for all entities or an array of specific entity classes/names.
568
+ * @default false
569
+ */
570
+ forceEntityConstructor: boolean | (Constructor<AnyEntity> | string)[];
571
+ /**
572
+ * Convert `null` values from database to `undefined` when hydrating entities.
573
+ * @default false
574
+ */
575
+ forceUndefined: boolean;
576
+ /**
577
+ * Property `onCreate` hooks are normally executed during `flush` operation.
578
+ * With this option, they will be processed early inside `em.create()` method.
579
+ * @default true
580
+ */
581
+ processOnCreateHooksEarly: boolean;
582
+ /**
583
+ * Force `Date` values to be stored in UTC for datetime columns without timezone.
584
+ * Works for MySQL (`datetime` type), PostgreSQL (`timestamp` type), and MSSQL (`datetime`/`datetime2` types).
585
+ * SQLite does this by default.
586
+ * @default true
587
+ */
588
+ forceUtcTimezone: boolean;
589
+ /**
590
+ * Timezone to use for date operations.
591
+ * @example '+02:00'
592
+ */
593
+ timezone?: string;
594
+ /**
595
+ * Ensure the database exists when initializing the ORM.
596
+ * When `true`, will create the database if it doesn't exist.
597
+ * @default true
598
+ */
599
+ ensureDatabase: boolean | EnsureDatabaseOptions;
600
+ /**
601
+ * Ensure database indexes exist on startup. This option works only with the MongoDB driver.
602
+ * When enabled, indexes will be created based on entity metadata.
603
+ * @default false
604
+ */
605
+ ensureIndexes: boolean;
606
+ /**
607
+ * Use batch insert queries for better performance.
608
+ * @default true
609
+ */
610
+ useBatchInserts?: boolean;
611
+ /**
612
+ * Use batch update queries for better performance.
613
+ * @default true
614
+ */
615
+ useBatchUpdates?: boolean;
616
+ /**
617
+ * Number of entities to process in each batch for batch inserts/updates.
618
+ * @default 300
619
+ */
620
+ batchSize: number;
621
+ /**
622
+ * Custom hydrator class for assigning database values to entities.
623
+ * @default ObjectHydrator
624
+ */
625
+ hydrator: HydratorConstructor;
626
+ /**
627
+ * Pre-generated compiled functions for hydration and comparison.
628
+ * Use the `compile` CLI command to create these functions.
629
+ * Enables deployment to runtimes that prohibit `new Function`/eval (e.g. Cloudflare Workers).
630
+ */
631
+ compiledFunctions?: CompiledFunctions;
632
+ /**
633
+ * Default loading strategy for relations.
634
+ * - `'joined'`: Use SQL JOINs (single query, may cause cartesian product)
635
+ * - `'select-in'`: Use separate SELECT IN queries (multiple queries)
636
+ * - `'balanced'`: Decides based on relation type and context.
637
+ * @default 'balanced'
638
+ */
639
+ loadStrategy: LoadStrategy | `${LoadStrategy}`;
640
+ /**
641
+ * Enable dataloader for batching reference loading.
642
+ * - `true` or `DataloaderType.ALL`: Enable for all relation types
643
+ * - `false` or `DataloaderType.NONE`: Disable dataloader
644
+ * - `DataloaderType.REFERENCE`: Enable only for scalar references
645
+ * - `DataloaderType.COLLECTION`: Enable only for collections
646
+ * @default DataloaderType.NONE
647
+ */
648
+ dataloader: DataloaderType | boolean;
649
+ /**
650
+ * Determines how where conditions are applied during population.
651
+ * - `'all'`: Populate all matching relations (default in v5+)
652
+ * - `'infer'`: Infer conditions from the original query (v4 behavior)
653
+ * @default 'all'
654
+ */
655
+ populateWhere: PopulateHint | `${PopulateHint}`;
656
+ /**
657
+ * Default flush mode for the entity manager.
658
+ * - `'commit'`: Flush only on explicit commit
659
+ * - `'auto'`: Flush before queries when needed
660
+ * - `'always'`: Always flush before queries
661
+ * @default 'auto'
662
+ */
663
+ flushMode: FlushMode | `${FlushMode}`;
664
+ /**
665
+ * Custom base repository class for all entities.
666
+ * Entity-specific repositories can still be defined and will take precedence.
667
+ * @see https://mikro-orm.io/docs/repositories
668
+ */
669
+ entityRepository?: EntityClass<EntityRepository<any>>;
670
+ /**
671
+ * Custom entity manager class to use.
672
+ */
673
+ entityManager?: Constructor<EM>;
674
+ /**
675
+ * Read replica connection configurations.
676
+ * Each replica can override parts of the main connection options.
677
+ * @see https://mikro-orm.io/docs/read-connections
678
+ */
679
+ replicas?: ConnectionOptions[];
680
+ /**
681
+ * Validate that required properties are set on new entities before insert.
682
+ * @default true
683
+ */
684
+ validateRequired: boolean;
685
+ /**
686
+ * Callback to get the current request context's EntityManager.
687
+ * Used for automatic context propagation in web frameworks.
688
+ * @default RequestContext.getEntityManager
689
+ */
690
+ context: (name: string) => EntityManager | undefined;
691
+ /**
692
+ * Name of the context for multi-ORM setups.
693
+ * @default 'default'
694
+ */
695
+ contextName: string;
696
+ /**
697
+ * Allow using the global EntityManager without a request context.
698
+ * Not recommended for production - each request should have its own context.
699
+ * Can also be set via `MIKRO_ORM_ALLOW_GLOBAL_CONTEXT` environment variable.
700
+ * @default false
701
+ */
702
+ allowGlobalContext: boolean;
703
+ /**
704
+ * When enabled, environment variables take precedence over explicitly provided config options.
705
+ * By default, explicit options win over env vars.
706
+ * @default false
707
+ */
708
+ preferEnvVars?: boolean;
709
+ /**
710
+ * Disable the identity map.
711
+ * When disabled, each query returns new entity instances.
712
+ * Not recommended for most use cases.
713
+ * @default false
714
+ */
715
+ disableIdentityMap?: boolean;
716
+ /**
717
+ * Custom logger function for ORM output.
718
+ * @default console.log
719
+ */
720
+ logger: (message: string) => void;
721
+ /**
722
+ * Enable colored output in logs.
723
+ * @default true
724
+ */
725
+ colors: boolean;
726
+ /**
727
+ * Factory function to create a custom logger instance.
728
+ * @default DefaultLogger.create
729
+ */
730
+ loggerFactory?: (options: LoggerOptions) => Logger;
731
+ /**
732
+ * Threshold in milliseconds for logging slow queries.
733
+ * Queries taking at least this long will be logged via the 'slow-query' namespace at warning level.
734
+ * Slow query logs are always emitted when the threshold is met, regardless of the `debug` setting.
735
+ * Set to `0` to log every query as slow.
736
+ * @default undefined (slow query logging disabled)
737
+ */
738
+ slowQueryThreshold?: number;
739
+ /**
740
+ * Factory function to create a custom logger instance for slow queries.
741
+ * Has the same shape as `loggerFactory`. When not provided, the main logger instance is used.
742
+ *
743
+ * Note: slow query log entries are emitted with `context.enabled = true` to bypass the
744
+ * debug-mode check. Custom logger implementations must respect `context.enabled` in their
745
+ * `isEnabled()` method (as `DefaultLogger` does) to ensure slow query logs are always emitted.
746
+ * @default undefined (falls back to main logger)
747
+ */
748
+ slowQueryLoggerFactory?: (options: LoggerOptions) => Logger;
749
+ /**
750
+ * Custom error handler for `em.findOneOrFail()` when no entity is found.
751
+ * @param entityName - Name of the entity being queried
752
+ * @param where - Query conditions
753
+ * @returns Error instance to throw
754
+ */
755
+ findOneOrFailHandler: (entityName: string, where: Dictionary | IPrimaryKey) => Error;
756
+ /**
757
+ * Custom error handler for `em.findExactlyOneOrFail()` when entity count is not exactly one.
758
+ * Used when strict mode is enabled.
759
+ * @param entityName - Name of the entity being queried
760
+ * @param where - Query conditions
761
+ * @returns Error instance to throw
762
+ */
763
+ findExactlyOneOrFailHandler: (entityName: string, where: Dictionary | IPrimaryKey) => Error;
764
+ /**
765
+ * Enable debug logging.
766
+ * Can be `true` for all namespaces or an array of specific namespaces.
767
+ * Available namespaces: `'query'`, `'query-params'`, `'discovery'`, `'info'`.
768
+ * @default false
769
+ * @see https://mikro-orm.io/docs/logging
770
+ */
771
+ debug: boolean | LoggerNamespace[];
772
+ /**
773
+ * Ignore deprecation warnings.
774
+ * Can be `true` to ignore all or an array of specific deprecation labels.
775
+ * @default false
776
+ * @see https://mikro-orm.io/docs/logging#deprecation-warnings
777
+ */
778
+ ignoreDeprecations: boolean | string[];
779
+ /**
780
+ * Syntax highlighter for SQL queries in logs.
781
+ * @default NullHighlighter
782
+ */
783
+ highlighter: Highlighter;
784
+ /**
785
+ * Force the ORM to use TypeScript options regardless of detection.
786
+ * Uses `entitiesTs` for discovery and `pathTs` for migrations/seeders.
787
+ * Should only be used for tests, not production builds.
788
+ * @default false
789
+ */
790
+ preferTs?: boolean;
791
+ /**
792
+ * Base directory for resolving relative paths.
793
+ * @default process.cwd()
794
+ */
795
+ baseDir: string;
796
+ /**
797
+ * Migration configuration options.
798
+ * @see https://mikro-orm.io/docs/migrations
799
+ */
800
+ migrations: MigrationsOptions;
801
+ /**
802
+ * Schema generator configuration options.
803
+ */
804
+ schemaGenerator: {
805
+ /**
806
+ * Try to disable foreign key checks during schema operations.
551
807
  * @default false
552
808
  */
553
- ensureIndexes: boolean;
554
- /**
555
- * Use batch insert queries for better performance.
556
- * @default true
557
- */
558
- useBatchInserts?: boolean;
559
- /**
560
- * Use batch update queries for better performance.
561
- * @default true
562
- */
563
- useBatchUpdates?: boolean;
564
- /**
565
- * Number of entities to process in each batch for batch inserts/updates.
566
- * @default 300
567
- */
568
- batchSize: number;
569
- /**
570
- * Custom hydrator class for assigning database values to entities.
571
- * @default ObjectHydrator
572
- */
573
- hydrator: HydratorConstructor;
574
- /**
575
- * Pre-generated compiled functions for hydration and comparison.
576
- * Use the `compile` CLI command to create these functions.
577
- * Enables deployment to runtimes that prohibit `new Function`/eval (e.g. Cloudflare Workers).
578
- */
579
- compiledFunctions?: CompiledFunctions;
580
- /**
581
- * Default loading strategy for relations.
582
- * - `'joined'`: Use SQL JOINs (single query, may cause cartesian product)
583
- * - `'select-in'`: Use separate SELECT IN queries (multiple queries)
584
- * - `'balanced'`: Decides based on relation type and context.
585
- * @default 'balanced'
586
- */
587
- loadStrategy: LoadStrategy | `${LoadStrategy}`;
588
- /**
589
- * Enable dataloader for batching reference loading.
590
- * - `true` or `DataloaderType.ALL`: Enable for all relation types
591
- * - `false` or `DataloaderType.NONE`: Disable dataloader
592
- * - `DataloaderType.REFERENCE`: Enable only for scalar references
593
- * - `DataloaderType.COLLECTION`: Enable only for collections
594
- * @default DataloaderType.NONE
595
- */
596
- dataloader: DataloaderType | boolean;
597
- /**
598
- * Determines how where conditions are applied during population.
599
- * - `'all'`: Populate all matching relations (default in v5+)
600
- * - `'infer'`: Infer conditions from the original query (v4 behavior)
601
- * @default 'all'
602
- */
603
- populateWhere: PopulateHint | `${PopulateHint}`;
604
- /**
605
- * Default flush mode for the entity manager.
606
- * - `'commit'`: Flush only on explicit commit
607
- * - `'auto'`: Flush before queries when needed
608
- * - `'always'`: Always flush before queries
609
- * @default 'auto'
610
- */
611
- flushMode: FlushMode | `${FlushMode}`;
612
- /**
613
- * Custom base repository class for all entities.
614
- * Entity-specific repositories can still be defined and will take precedence.
615
- * @see https://mikro-orm.io/docs/repositories
616
- */
617
- entityRepository?: EntityClass<EntityRepository<any>>;
618
- /**
619
- * Custom entity manager class to use.
620
- */
621
- entityManager?: Constructor<EM>;
809
+ disableForeignKeys?: boolean;
622
810
  /**
623
- * Read replica connection configurations.
624
- * Each replica can override parts of the main connection options.
625
- * @see https://mikro-orm.io/docs/read-connections
811
+ * Try to disable foreign key checks during `schema.clear()`. Enabled by default for MySQL/MariaDB.
626
812
  */
627
- replicas?: ConnectionOptions[];
813
+ disableForeignKeysForClear?: boolean;
628
814
  /**
629
- * Validate that required properties are set on new entities before insert.
815
+ * Generate foreign key constraints.
630
816
  * @default true
631
817
  */
632
- validateRequired: boolean;
633
- /**
634
- * Callback to get the current request context's EntityManager.
635
- * Used for automatic context propagation in web frameworks.
636
- * @default RequestContext.getEntityManager
637
- */
638
- context: (name: string) => EntityManager | undefined;
639
- /**
640
- * Name of the context for multi-ORM setups.
641
- * @default 'default'
642
- */
643
- contextName: string;
818
+ createForeignKeyConstraints?: boolean;
644
819
  /**
645
- * Allow using the global EntityManager without a request context.
646
- * Not recommended for production - each request should have its own context.
647
- * Can also be set via `MIKRO_ORM_ALLOW_GLOBAL_CONTEXT` environment variable.
648
- * @default false
649
- */
650
- allowGlobalContext: boolean;
651
- /**
652
- * When enabled, environment variables take precedence over explicitly provided config options.
653
- * By default, explicit options win over env vars.
654
- * @default false
820
+ * Schema names to ignore when comparing schemas.
821
+ * @default []
655
822
  */
656
- preferEnvVars?: boolean;
823
+ ignoreSchema?: string[];
657
824
  /**
658
- * Disable the identity map.
659
- * When disabled, each query returns new entity instances.
660
- * Not recommended for most use cases.
661
- * @default false
825
+ * Table names or patterns to skip during schema generation.
826
+ * @default []
662
827
  */
663
- disableIdentityMap?: boolean;
828
+ skipTables?: (string | RegExp)[];
664
829
  /**
665
- * Custom logger function for ORM output.
666
- * @default console.log
830
+ * View names or patterns to skip during schema generation (e.g. PostGIS system views).
831
+ * @default []
667
832
  */
668
- logger: (message: string) => void;
833
+ skipViews?: (string | RegExp)[];
669
834
  /**
670
- * Enable colored output in logs.
671
- * @default true
835
+ * Column names or patterns to skip during schema generation, keyed by table name.
836
+ * @default {}
672
837
  */
673
- colors: boolean;
838
+ skipColumns?: Dictionary<(string | RegExp)[]>;
674
839
  /**
675
- * Factory function to create a custom logger instance.
676
- * @default DefaultLogger.create
840
+ * Database name to use for management operations (e.g., creating/dropping databases).
677
841
  */
678
- loggerFactory?: (options: LoggerOptions) => Logger;
842
+ managementDbName?: string;
679
843
  /**
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)
844
+ * Default ON UPDATE rule for foreign keys.
845
+ * When not set, no rule is emitted and the database uses its native default (NO ACTION/RESTRICT).
685
846
  */
686
- slowQueryThreshold?: number;
847
+ defaultUpdateRule?: 'cascade' | 'no action' | 'set null' | 'set default' | 'restrict';
687
848
  /**
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)
849
+ * Default ON DELETE rule for foreign keys.
850
+ * When not set, no rule is emitted and the database uses its native default (NO ACTION/RESTRICT).
695
851
  */
696
- slowQueryLoggerFactory?: (options: LoggerOptions) => Logger;
852
+ defaultDeleteRule?: 'cascade' | 'no action' | 'set null' | 'set default' | 'restrict';
853
+ tableSpace?: string;
854
+ };
855
+ /**
856
+ * Embeddable entity configuration options.
857
+ */
858
+ embeddables: {
697
859
  /**
698
- * Custom error handler for `em.findOneOrFail()` when no entity is found.
699
- * @param entityName - Name of the entity being queried
700
- * @param where - Query conditions
701
- * @returns Error instance to throw
860
+ * Mode for generating column prefixes for embedded properties.
861
+ * @default 'relative'
702
862
  */
703
- findOneOrFailHandler: (entityName: string, where: Dictionary | IPrimaryKey) => Error;
863
+ prefixMode: EmbeddedPrefixMode;
864
+ };
865
+ /**
866
+ * Entity generator (code generation) configuration options.
867
+ * @see https://mikro-orm.io/docs/entity-generator
868
+ */
869
+ entityGenerator: GenerateOptions;
870
+ /**
871
+ * Metadata cache configuration for improved startup performance.
872
+ * @see https://mikro-orm.io/docs/metadata-cache
873
+ */
874
+ metadataCache: {
704
875
  /**
705
- * Custom error handler for `em.findExactlyOneOrFail()` when entity count is not exactly one.
706
- * Used when strict mode is enabled.
707
- * @param entityName - Name of the entity being queried
708
- * @param where - Query conditions
709
- * @returns Error instance to throw
876
+ * Enable metadata caching.
877
+ * Defaults based on the metadata provider's `useCache()` method.
710
878
  */
711
- findExactlyOneOrFailHandler: (entityName: string, where: Dictionary | IPrimaryKey) => Error;
879
+ enabled?: boolean;
712
880
  /**
713
- * Enable debug logging.
714
- * Can be `true` for all namespaces or an array of specific namespaces.
715
- * Available namespaces: `'query'`, `'query-params'`, `'discovery'`, `'info'`.
716
- * @default false
717
- * @see https://mikro-orm.io/docs/logging
881
+ * Combine all metadata into a single cache file.
882
+ * Can be `true` for default path or a custom path string.
718
883
  */
719
- debug: boolean | LoggerNamespace[];
884
+ combined?: boolean | string;
720
885
  /**
721
- * Ignore deprecation warnings.
722
- * Can be `true` to ignore all or an array of specific deprecation labels.
886
+ * Pretty print JSON cache files.
723
887
  * @default false
724
- * @see https://mikro-orm.io/docs/logging#deprecation-warnings
725
888
  */
726
- ignoreDeprecations: boolean | string[];
889
+ pretty?: boolean;
727
890
  /**
728
- * Syntax highlighter for SQL queries in logs.
729
- * @default NullHighlighter
891
+ * Cache adapter class to use. When cache is enabled, and no adapter is provided explicitly, {@link FileCacheAdapter} is used automatically - but only if you use the async `MikroORM.init()` method.
730
892
  */
731
- highlighter: Highlighter;
732
- /**
733
- * Force the ORM to use TypeScript options regardless of detection.
734
- * Uses `entitiesTs` for discovery and `pathTs` for migrations/seeders.
735
- * Should only be used for tests, not production builds.
736
- * @default false
737
- */
738
- preferTs?: boolean;
739
- /**
740
- * Base directory for resolving relative paths.
741
- * @default process.cwd()
742
- */
743
- baseDir: string;
744
- /**
745
- * Migration configuration options.
746
- * @see https://mikro-orm.io/docs/migrations
747
- */
748
- migrations: MigrationsOptions;
749
- /**
750
- * Schema generator configuration options.
751
- */
752
- schemaGenerator: {
753
- /**
754
- * Try to disable foreign key checks during schema operations.
755
- * @default false
756
- */
757
- disableForeignKeys?: boolean;
758
- /**
759
- * Try to disable foreign key checks during `schema.clear()`. Enabled by default for MySQL/MariaDB.
760
- */
761
- disableForeignKeysForClear?: boolean;
762
- /**
763
- * Generate foreign key constraints.
764
- * @default true
765
- */
766
- createForeignKeyConstraints?: boolean;
767
- /**
768
- * Schema names to ignore when comparing schemas.
769
- * @default []
770
- */
771
- ignoreSchema?: string[];
772
- /**
773
- * Table names or patterns to skip during schema generation.
774
- * @default []
775
- */
776
- skipTables?: (string | RegExp)[];
777
- /**
778
- * View names or patterns to skip during schema generation (e.g. PostGIS system views).
779
- * @default []
780
- */
781
- skipViews?: (string | RegExp)[];
782
- /**
783
- * Column names or patterns to skip during schema generation, keyed by table name.
784
- * @default {}
785
- */
786
- skipColumns?: Dictionary<(string | RegExp)[]>;
787
- /**
788
- * Database name to use for management operations (e.g., creating/dropping databases).
789
- */
790
- managementDbName?: string;
791
- /**
792
- * Default ON UPDATE rule for foreign keys.
793
- * When not set, no rule is emitted and the database uses its native default (NO ACTION/RESTRICT).
794
- */
795
- defaultUpdateRule?: 'cascade' | 'no action' | 'set null' | 'set default' | 'restrict';
796
- /**
797
- * Default ON DELETE rule for foreign keys.
798
- * When not set, no rule is emitted and the database uses its native default (NO ACTION/RESTRICT).
799
- */
800
- defaultDeleteRule?: 'cascade' | 'no action' | 'set null' | 'set default' | 'restrict';
801
- tableSpace?: string;
802
- };
803
- /**
804
- * Embeddable entity configuration options.
805
- */
806
- embeddables: {
807
- /**
808
- * Mode for generating column prefixes for embedded properties.
809
- * @default 'relative'
810
- */
811
- prefixMode: EmbeddedPrefixMode;
893
+ adapter?: {
894
+ new (...params: any[]): SyncCacheAdapter;
812
895
  };
813
896
  /**
814
- * Entity generator (code generation) configuration options.
815
- * @see https://mikro-orm.io/docs/entity-generator
897
+ * Options passed to the cache adapter constructor.
898
+ * @default { cacheDir: process.cwd() + '/temp' }
816
899
  */
817
- entityGenerator: GenerateOptions;
818
- /**
819
- * Metadata cache configuration for improved startup performance.
820
- * @see https://mikro-orm.io/docs/metadata-cache
821
- */
822
- metadataCache: {
823
- /**
824
- * Enable metadata caching.
825
- * Defaults based on the metadata provider's `useCache()` method.
826
- */
827
- enabled?: boolean;
828
- /**
829
- * Combine all metadata into a single cache file.
830
- * Can be `true` for default path or a custom path string.
831
- */
832
- combined?: boolean | string;
833
- /**
834
- * Pretty print JSON cache files.
835
- * @default false
836
- */
837
- pretty?: boolean;
838
- /**
839
- * Cache adapter class to use. When cache is enabled, and no adapter is provided explicitly, {@link FileCacheAdapter} is used automatically - but only if you use the async `MikroORM.init()` method.
840
- */
841
- adapter?: {
842
- new (...params: any[]): SyncCacheAdapter;
843
- };
844
- /**
845
- * Options passed to the cache adapter constructor.
846
- * @default { cacheDir: process.cwd() + '/temp' }
847
- */
848
- options?: Dictionary;
849
- };
900
+ options?: Dictionary;
901
+ };
902
+ /**
903
+ * Result cache configuration for query result caching.
904
+ */
905
+ resultCache: {
850
906
  /**
851
- * Result cache configuration for query result caching.
907
+ * Default cache expiration time in milliseconds.
908
+ * @default 1000
852
909
  */
853
- resultCache: {
854
- /**
855
- * Default cache expiration time in milliseconds.
856
- * @default 1000
857
- */
858
- expiration?: number;
859
- /**
860
- * Cache adapter class to use.
861
- * @default MemoryCacheAdapter
862
- */
863
- adapter?: {
864
- new (...params: any[]): CacheAdapter;
865
- };
866
- /**
867
- * Options passed to the cache adapter constructor.
868
- * @default {}
869
- */
870
- options?: Dictionary;
871
- /**
872
- * Enable global result caching for all queries.
873
- * Can be `true`, an expiration number, or a tuple of `[key, expiration]`.
874
- */
875
- global?: boolean | number | [string, number];
876
- };
910
+ expiration?: number;
877
911
  /**
878
- * Metadata provider class for entity discovery.
879
- * Built-in options: `ReflectMetadataProvider` (default), `TsMorphMetadataProvider`.
880
- * @default ReflectMetadataProvider
881
- * @see https://mikro-orm.io/docs/metadata-providers
912
+ * Cache adapter class to use.
913
+ * @default MemoryCacheAdapter
882
914
  */
883
- metadataProvider: {
884
- new (config: Configuration): MetadataProvider;
885
- useCache?: MetadataProvider['useCache'];
915
+ adapter?: {
916
+ new (...params: any[]): CacheAdapter;
886
917
  };
887
918
  /**
888
- * Seeder configuration options.
889
- * @see https://mikro-orm.io/docs/seeding
890
- */
891
- seeder: SeederOptions;
892
- /**
893
- * Prefer read replicas for read operations when available.
894
- * @default true
895
- */
896
- preferReadReplicas: boolean;
897
- /**
898
- * Custom dynamic import provider for loading modules.
899
- * @default (id) => import(id)
900
- */
901
- dynamicImportProvider: (id: string) => Promise<unknown>;
919
+ * Options passed to the cache adapter constructor.
920
+ * @default {}
921
+ */
922
+ options?: Dictionary;
923
+ /**
924
+ * Enable global result caching for all queries.
925
+ * Can be `true`, an expiration number, or a tuple of `[key, expiration]`.
926
+ */
927
+ global?: boolean | number | [string, number];
928
+ };
929
+ /**
930
+ * Metadata provider class for entity discovery.
931
+ * Built-in options: `ReflectMetadataProvider` (default), `TsMorphMetadataProvider`.
932
+ * @default ReflectMetadataProvider
933
+ * @see https://mikro-orm.io/docs/metadata-providers
934
+ */
935
+ metadataProvider: {
936
+ new (config: Configuration): MetadataProvider;
937
+ useCache?: MetadataProvider['useCache'];
938
+ };
939
+ /**
940
+ * Seeder configuration options.
941
+ * @see https://mikro-orm.io/docs/seeding
942
+ */
943
+ seeder: SeederOptions;
944
+ /**
945
+ * Prefer read replicas for read operations when available.
946
+ * @default true
947
+ */
948
+ preferReadReplicas: boolean;
949
+ /**
950
+ * Custom dynamic import provider for loading modules.
951
+ * @default (id) => import(id)
952
+ */
953
+ dynamicImportProvider: (id: string) => Promise<unknown>;
902
954
  }