@mikro-orm/core 7.0.4-dev.8 → 7.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/EntityManager.d.ts +884 -583
- package/EntityManager.js +1922 -1895
- package/MikroORM.d.ts +103 -74
- package/MikroORM.js +178 -179
- package/README.md +1 -1
- package/cache/CacheAdapter.d.ts +36 -36
- package/cache/FileCacheAdapter.d.ts +30 -24
- package/cache/FileCacheAdapter.js +80 -78
- package/cache/GeneratedCacheAdapter.d.ts +18 -20
- package/cache/GeneratedCacheAdapter.js +30 -30
- package/cache/MemoryCacheAdapter.d.ts +18 -20
- package/cache/MemoryCacheAdapter.js +35 -36
- package/cache/NullCacheAdapter.d.ts +16 -16
- package/cache/NullCacheAdapter.js +24 -24
- package/connections/Connection.d.ts +95 -84
- package/connections/Connection.js +165 -168
- package/drivers/DatabaseDriver.d.ts +186 -80
- package/drivers/DatabaseDriver.js +450 -443
- package/drivers/IDatabaseDriver.d.ts +440 -301
- package/entity/BaseEntity.d.ts +120 -83
- package/entity/BaseEntity.js +43 -43
- package/entity/Collection.d.ts +212 -179
- package/entity/Collection.js +727 -721
- package/entity/EntityAssigner.d.ts +88 -77
- package/entity/EntityAssigner.js +231 -230
- package/entity/EntityFactory.d.ts +66 -54
- package/entity/EntityFactory.js +425 -383
- package/entity/EntityHelper.d.ts +34 -22
- package/entity/EntityHelper.js +280 -267
- package/entity/EntityIdentifier.d.ts +4 -4
- package/entity/EntityIdentifier.js +10 -10
- package/entity/EntityLoader.d.ts +98 -72
- package/entity/EntityLoader.js +753 -723
- package/entity/EntityRepository.d.ts +316 -201
- package/entity/EntityRepository.js +213 -213
- package/entity/PolymorphicRef.d.ts +5 -5
- package/entity/PolymorphicRef.js +10 -10
- package/entity/Reference.d.ts +126 -82
- package/entity/Reference.js +278 -274
- package/entity/WrappedEntity.d.ts +115 -72
- package/entity/WrappedEntity.js +168 -166
- package/entity/defineEntity.d.ts +1315 -636
- package/entity/defineEntity.js +527 -518
- package/entity/utils.d.ts +13 -3
- package/entity/utils.js +71 -73
- package/entity/validators.js +43 -43
- package/entity/wrap.js +8 -8
- package/enums.d.ts +258 -253
- package/enums.js +251 -252
- package/errors.d.ts +114 -72
- package/errors.js +350 -253
- package/events/EventManager.d.ts +26 -14
- package/events/EventManager.js +79 -77
- package/events/EventSubscriber.d.ts +29 -29
- package/events/TransactionEventBroadcaster.d.ts +15 -8
- package/events/TransactionEventBroadcaster.js +14 -14
- package/exceptions.d.ts +23 -40
- package/exceptions.js +35 -52
- package/hydration/Hydrator.d.ts +42 -17
- package/hydration/Hydrator.js +43 -43
- package/hydration/ObjectHydrator.d.ts +50 -17
- package/hydration/ObjectHydrator.js +481 -416
- package/index.d.ts +116 -2
- package/index.js +10 -1
- package/logging/DefaultLogger.d.ts +34 -32
- package/logging/DefaultLogger.js +86 -86
- package/logging/Logger.d.ts +41 -41
- package/logging/SimpleLogger.d.ts +13 -11
- package/logging/SimpleLogger.js +22 -22
- package/logging/colors.d.ts +6 -6
- package/logging/colors.js +11 -10
- package/logging/inspect.js +7 -7
- package/metadata/EntitySchema.d.ts +211 -127
- package/metadata/EntitySchema.js +397 -398
- package/metadata/MetadataDiscovery.d.ts +114 -114
- package/metadata/MetadataDiscovery.js +1951 -1863
- package/metadata/MetadataProvider.d.ts +24 -21
- package/metadata/MetadataProvider.js +82 -84
- package/metadata/MetadataStorage.d.ts +38 -32
- package/metadata/MetadataStorage.js +118 -118
- package/metadata/MetadataValidator.d.ts +39 -39
- package/metadata/MetadataValidator.js +381 -338
- package/metadata/discover-entities.d.ts +5 -2
- package/metadata/discover-entities.js +35 -27
- package/metadata/types.d.ts +615 -531
- package/naming-strategy/AbstractNamingStrategy.d.ts +54 -39
- package/naming-strategy/AbstractNamingStrategy.js +90 -85
- package/naming-strategy/EntityCaseNamingStrategy.d.ts +6 -6
- package/naming-strategy/EntityCaseNamingStrategy.js +22 -22
- package/naming-strategy/MongoNamingStrategy.d.ts +6 -6
- package/naming-strategy/MongoNamingStrategy.js +18 -18
- package/naming-strategy/NamingStrategy.d.ts +109 -99
- package/naming-strategy/UnderscoreNamingStrategy.d.ts +7 -7
- package/naming-strategy/UnderscoreNamingStrategy.js +21 -21
- package/not-supported.js +7 -4
- package/package.json +1 -1
- package/platforms/ExceptionConverter.d.ts +1 -1
- package/platforms/ExceptionConverter.js +4 -4
- package/platforms/Platform.d.ts +310 -299
- package/platforms/Platform.js +663 -636
- package/serialization/EntitySerializer.d.ts +49 -26
- package/serialization/EntitySerializer.js +224 -218
- package/serialization/EntityTransformer.d.ts +10 -6
- package/serialization/EntityTransformer.js +219 -217
- package/serialization/SerializationContext.d.ts +27 -23
- package/serialization/SerializationContext.js +105 -105
- package/types/ArrayType.d.ts +8 -8
- package/types/ArrayType.js +33 -33
- package/types/BigIntType.d.ts +17 -10
- package/types/BigIntType.js +37 -37
- package/types/BlobType.d.ts +3 -3
- package/types/BlobType.js +13 -13
- package/types/BooleanType.d.ts +4 -4
- package/types/BooleanType.js +12 -12
- package/types/CharacterType.d.ts +2 -2
- package/types/CharacterType.js +6 -6
- package/types/DateTimeType.d.ts +5 -5
- package/types/DateTimeType.js +15 -15
- package/types/DateType.d.ts +5 -5
- package/types/DateType.js +15 -15
- package/types/DecimalType.d.ts +7 -7
- package/types/DecimalType.js +26 -26
- package/types/DoubleType.d.ts +3 -3
- package/types/DoubleType.js +12 -12
- package/types/EnumArrayType.d.ts +5 -5
- package/types/EnumArrayType.js +24 -24
- package/types/EnumType.d.ts +3 -3
- package/types/EnumType.js +11 -11
- package/types/FloatType.d.ts +3 -3
- package/types/FloatType.js +9 -9
- package/types/IntegerType.d.ts +3 -3
- package/types/IntegerType.js +9 -9
- package/types/IntervalType.d.ts +4 -4
- package/types/IntervalType.js +12 -12
- package/types/JsonType.d.ts +8 -8
- package/types/JsonType.js +32 -32
- package/types/MediumIntType.d.ts +1 -1
- package/types/MediumIntType.js +3 -3
- package/types/SmallIntType.d.ts +3 -3
- package/types/SmallIntType.js +9 -9
- package/types/StringType.d.ts +4 -4
- package/types/StringType.js +12 -12
- package/types/TextType.d.ts +3 -3
- package/types/TextType.js +9 -9
- package/types/TimeType.d.ts +5 -5
- package/types/TimeType.js +17 -17
- package/types/TinyIntType.d.ts +3 -3
- package/types/TinyIntType.js +10 -10
- package/types/Type.d.ts +83 -79
- package/types/Type.js +82 -82
- package/types/Uint8ArrayType.d.ts +4 -4
- package/types/Uint8ArrayType.js +21 -21
- package/types/UnknownType.d.ts +4 -4
- package/types/UnknownType.js +12 -12
- package/types/UuidType.d.ts +5 -5
- package/types/UuidType.js +19 -19
- package/types/index.d.ts +75 -49
- package/types/index.js +52 -26
- package/typings.d.ts +1250 -737
- package/typings.js +244 -231
- package/unit-of-work/ChangeSet.d.ts +26 -26
- package/unit-of-work/ChangeSet.js +56 -56
- package/unit-of-work/ChangeSetComputer.d.ts +12 -12
- package/unit-of-work/ChangeSetComputer.js +178 -170
- package/unit-of-work/ChangeSetPersister.d.ts +63 -44
- package/unit-of-work/ChangeSetPersister.js +442 -421
- package/unit-of-work/CommitOrderCalculator.d.ts +40 -40
- package/unit-of-work/CommitOrderCalculator.js +89 -88
- package/unit-of-work/IdentityMap.d.ts +31 -31
- package/unit-of-work/IdentityMap.js +105 -105
- package/unit-of-work/UnitOfWork.d.ts +181 -141
- package/unit-of-work/UnitOfWork.js +1200 -1183
- package/utils/AbstractMigrator.d.ts +111 -91
- package/utils/AbstractMigrator.js +275 -275
- package/utils/AbstractSchemaGenerator.d.ts +43 -34
- package/utils/AbstractSchemaGenerator.js +121 -122
- package/utils/AsyncContext.d.ts +3 -3
- package/utils/AsyncContext.js +34 -35
- package/utils/Configuration.d.ts +852 -808
- package/utils/Configuration.js +359 -344
- package/utils/Cursor.d.ts +40 -22
- package/utils/Cursor.js +135 -127
- package/utils/DataloaderUtils.d.ts +58 -43
- package/utils/DataloaderUtils.js +203 -198
- package/utils/EntityComparator.d.ts +98 -81
- package/utils/EntityComparator.js +828 -728
- package/utils/NullHighlighter.d.ts +1 -1
- package/utils/NullHighlighter.js +3 -3
- package/utils/QueryHelper.d.ts +79 -51
- package/utils/QueryHelper.js +372 -361
- package/utils/RawQueryFragment.d.ts +50 -34
- package/utils/RawQueryFragment.js +107 -105
- package/utils/RequestContext.d.ts +32 -32
- package/utils/RequestContext.js +52 -53
- package/utils/TransactionContext.d.ts +16 -16
- package/utils/TransactionContext.js +27 -27
- package/utils/TransactionManager.d.ts +58 -58
- package/utils/TransactionManager.js +199 -197
- package/utils/Utils.d.ts +204 -145
- package/utils/Utils.js +812 -810
- package/utils/clone.js +104 -113
- package/utils/env-vars.js +90 -88
- package/utils/fs-utils.d.ts +15 -15
- package/utils/fs-utils.js +180 -181
- package/utils/upsert-utils.d.ts +20 -5
- package/utils/upsert-utils.js +114 -116
package/utils/Configuration.d.ts
CHANGED
|
@@ -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 {
|
|
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';
|
|
@@ -16,895 +36,919 @@ import { EntityComparator } from './EntityComparator.js';
|
|
|
16
36
|
import type { Type } from '../types/Type.js';
|
|
17
37
|
import type { MikroORM } from '../MikroORM.js';
|
|
18
38
|
/** Holds and validates all ORM configuration options, providing access to drivers, loggers, cache adapters, and other services. */
|
|
19
|
-
export declare class Configuration<
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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;
|
|
98
123
|
}
|
|
99
124
|
/**
|
|
100
125
|
* Type helper to make it easier to use `mikro-orm.config.js`.
|
|
101
126
|
*/
|
|
102
|
-
export declare function defineConfig<
|
|
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>>;
|
|
103
136
|
/**
|
|
104
137
|
* Connection configuration options for database connections.
|
|
105
138
|
* @see https://mikro-orm.io/docs/configuration#connection
|
|
106
139
|
*/
|
|
107
140
|
export interface ConnectionOptions {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
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
|
+
}[];
|
|
164
197
|
}
|
|
165
198
|
/**
|
|
166
199
|
* Configuration options for database migrations.
|
|
167
200
|
* @see https://mikro-orm.io/docs/migrations
|
|
168
201
|
*/
|
|
169
202
|
export type MigrationsOptions = {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
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>)[];
|
|
241
274
|
};
|
|
242
275
|
/**
|
|
243
276
|
* Configuration options for database seeders.
|
|
244
277
|
* @see https://mikro-orm.io/docs/seeding
|
|
245
278
|
*/
|
|
246
279
|
export interface SeederOptions {
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
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>)[];
|
|
279
312
|
}
|
|
280
313
|
/**
|
|
281
314
|
* Connection pool configuration.
|
|
282
315
|
* @see https://mikro-orm.io/docs/configuration#connection
|
|
283
316
|
*/
|
|
284
317
|
export interface PoolConfig {
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
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;
|
|
291
324
|
}
|
|
292
325
|
/**
|
|
293
326
|
* Configuration options for metadata discovery.
|
|
294
327
|
* @see https://mikro-orm.io/docs/configuration#entity-discovery
|
|
295
328
|
*/
|
|
296
329
|
export interface MetadataDiscoveryOptions {
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
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;
|
|
350
383
|
}
|
|
351
384
|
/**
|
|
352
385
|
* MikroORM configuration options.
|
|
353
386
|
* @see https://mikro-orm.io/docs/configuration
|
|
354
387
|
*/
|
|
355
|
-
export interface Options<
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
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.
|
|
480
539
|
* @default true
|
|
481
540
|
*/
|
|
482
|
-
|
|
541
|
+
includePrimaryKeys?: boolean;
|
|
483
542
|
/**
|
|
484
|
-
*
|
|
485
|
-
*
|
|
486
|
-
* @default true
|
|
487
|
-
*/
|
|
488
|
-
populateAfterFlush: boolean;
|
|
489
|
-
/**
|
|
490
|
-
* Serialization options for `toJSON()` and `serialize()` methods.
|
|
491
|
-
*/
|
|
492
|
-
serialization: {
|
|
493
|
-
/**
|
|
494
|
-
* Include primary keys in serialized output.
|
|
495
|
-
* @default true
|
|
496
|
-
*/
|
|
497
|
-
includePrimaryKeys?: boolean;
|
|
498
|
-
/**
|
|
499
|
-
* Enforce unpopulated references to be returned as objects.
|
|
500
|
-
* When enabled, references are serialized as `{ author: { id: 1 } }` instead of `{ author: 1 }`.
|
|
501
|
-
* @default false
|
|
502
|
-
*/
|
|
503
|
-
forceObject?: boolean;
|
|
504
|
-
};
|
|
505
|
-
/**
|
|
506
|
-
* Default options for entity assignment via `em.assign()`.
|
|
507
|
-
* @see https://mikro-orm.io/docs/entity-helper
|
|
508
|
-
*/
|
|
509
|
-
assign: AssignOptions<boolean>;
|
|
510
|
-
/**
|
|
511
|
-
* Automatically call `em.persist()` on entities created via `em.create()`.
|
|
512
|
-
* @default true
|
|
513
|
-
*/
|
|
514
|
-
persistOnCreate: boolean;
|
|
515
|
-
/**
|
|
516
|
-
* When upsert creates a new entity, mark it as managed in the identity map.
|
|
517
|
-
* @default true
|
|
518
|
-
*/
|
|
519
|
-
upsertManaged: boolean;
|
|
520
|
-
/**
|
|
521
|
-
* Force use of entity constructors when creating entity instances.
|
|
522
|
-
* Required when using native private properties inside entities.
|
|
523
|
-
* 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 }`.
|
|
524
545
|
* @default false
|
|
525
546
|
*/
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
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.
|
|
559
807
|
* @default false
|
|
560
808
|
*/
|
|
561
|
-
|
|
562
|
-
/**
|
|
563
|
-
* Use batch insert queries for better performance.
|
|
564
|
-
* @default true
|
|
565
|
-
*/
|
|
566
|
-
useBatchInserts?: boolean;
|
|
567
|
-
/**
|
|
568
|
-
* Use batch update queries for better performance.
|
|
569
|
-
* @default true
|
|
570
|
-
*/
|
|
571
|
-
useBatchUpdates?: boolean;
|
|
572
|
-
/**
|
|
573
|
-
* Number of entities to process in each batch for batch inserts/updates.
|
|
574
|
-
* @default 300
|
|
575
|
-
*/
|
|
576
|
-
batchSize: number;
|
|
577
|
-
/**
|
|
578
|
-
* Custom hydrator class for assigning database values to entities.
|
|
579
|
-
* @default ObjectHydrator
|
|
580
|
-
*/
|
|
581
|
-
hydrator: HydratorConstructor;
|
|
582
|
-
/**
|
|
583
|
-
* Pre-generated compiled functions for hydration and comparison.
|
|
584
|
-
* Use the `compile` CLI command to create these functions.
|
|
585
|
-
* Enables deployment to runtimes that prohibit `new Function`/eval (e.g. Cloudflare Workers).
|
|
586
|
-
*/
|
|
587
|
-
compiledFunctions?: CompiledFunctions;
|
|
588
|
-
/**
|
|
589
|
-
* Default loading strategy for relations.
|
|
590
|
-
* - `'joined'`: Use SQL JOINs (single query, may cause cartesian product)
|
|
591
|
-
* - `'select-in'`: Use separate SELECT IN queries (multiple queries)
|
|
592
|
-
* - `'balanced'`: Decides based on relation type and context.
|
|
593
|
-
* @default 'balanced'
|
|
594
|
-
*/
|
|
595
|
-
loadStrategy: LoadStrategy | `${LoadStrategy}`;
|
|
596
|
-
/**
|
|
597
|
-
* Enable dataloader for batching reference loading.
|
|
598
|
-
* - `true` or `DataloaderType.ALL`: Enable for all relation types
|
|
599
|
-
* - `false` or `DataloaderType.NONE`: Disable dataloader
|
|
600
|
-
* - `DataloaderType.REFERENCE`: Enable only for scalar references
|
|
601
|
-
* - `DataloaderType.COLLECTION`: Enable only for collections
|
|
602
|
-
* @default DataloaderType.NONE
|
|
603
|
-
*/
|
|
604
|
-
dataloader: DataloaderType | boolean;
|
|
605
|
-
/**
|
|
606
|
-
* Determines how where conditions are applied during population.
|
|
607
|
-
* - `'all'`: Populate all matching relations (default in v5+)
|
|
608
|
-
* - `'infer'`: Infer conditions from the original query (v4 behavior)
|
|
609
|
-
* @default 'all'
|
|
610
|
-
*/
|
|
611
|
-
populateWhere: PopulateHint | `${PopulateHint}`;
|
|
612
|
-
/**
|
|
613
|
-
* Default flush mode for the entity manager.
|
|
614
|
-
* - `'commit'`: Flush only on explicit commit
|
|
615
|
-
* - `'auto'`: Flush before queries when needed
|
|
616
|
-
* - `'always'`: Always flush before queries
|
|
617
|
-
* @default 'auto'
|
|
618
|
-
*/
|
|
619
|
-
flushMode: FlushMode | `${FlushMode}`;
|
|
620
|
-
/**
|
|
621
|
-
* Custom base repository class for all entities.
|
|
622
|
-
* Entity-specific repositories can still be defined and will take precedence.
|
|
623
|
-
* @see https://mikro-orm.io/docs/repositories
|
|
624
|
-
*/
|
|
625
|
-
entityRepository?: EntityClass<EntityRepository<any>>;
|
|
626
|
-
/**
|
|
627
|
-
* Custom entity manager class to use.
|
|
628
|
-
*/
|
|
629
|
-
entityManager?: Constructor<EM>;
|
|
809
|
+
disableForeignKeys?: boolean;
|
|
630
810
|
/**
|
|
631
|
-
*
|
|
632
|
-
* Each replica can override parts of the main connection options.
|
|
633
|
-
* @see https://mikro-orm.io/docs/read-connections
|
|
811
|
+
* Try to disable foreign key checks during `schema.clear()`. Enabled by default for MySQL/MariaDB.
|
|
634
812
|
*/
|
|
635
|
-
|
|
813
|
+
disableForeignKeysForClear?: boolean;
|
|
636
814
|
/**
|
|
637
|
-
*
|
|
815
|
+
* Generate foreign key constraints.
|
|
638
816
|
* @default true
|
|
639
817
|
*/
|
|
640
|
-
|
|
641
|
-
/**
|
|
642
|
-
* Callback to get the current request context's EntityManager.
|
|
643
|
-
* Used for automatic context propagation in web frameworks.
|
|
644
|
-
* @default RequestContext.getEntityManager
|
|
645
|
-
*/
|
|
646
|
-
context: (name: string) => EntityManager | undefined;
|
|
647
|
-
/**
|
|
648
|
-
* Name of the context for multi-ORM setups.
|
|
649
|
-
* @default 'default'
|
|
650
|
-
*/
|
|
651
|
-
contextName: string;
|
|
818
|
+
createForeignKeyConstraints?: boolean;
|
|
652
819
|
/**
|
|
653
|
-
*
|
|
654
|
-
*
|
|
655
|
-
* Can also be set via `MIKRO_ORM_ALLOW_GLOBAL_CONTEXT` environment variable.
|
|
656
|
-
* @default false
|
|
657
|
-
*/
|
|
658
|
-
allowGlobalContext: boolean;
|
|
659
|
-
/**
|
|
660
|
-
* When enabled, environment variables take precedence over explicitly provided config options.
|
|
661
|
-
* By default, explicit options win over env vars.
|
|
662
|
-
* @default false
|
|
820
|
+
* Schema names to ignore when comparing schemas.
|
|
821
|
+
* @default []
|
|
663
822
|
*/
|
|
664
|
-
|
|
823
|
+
ignoreSchema?: string[];
|
|
665
824
|
/**
|
|
666
|
-
*
|
|
667
|
-
*
|
|
668
|
-
* Not recommended for most use cases.
|
|
669
|
-
* @default false
|
|
825
|
+
* Table names or patterns to skip during schema generation.
|
|
826
|
+
* @default []
|
|
670
827
|
*/
|
|
671
|
-
|
|
828
|
+
skipTables?: (string | RegExp)[];
|
|
672
829
|
/**
|
|
673
|
-
*
|
|
674
|
-
* @default
|
|
830
|
+
* View names or patterns to skip during schema generation (e.g. PostGIS system views).
|
|
831
|
+
* @default []
|
|
675
832
|
*/
|
|
676
|
-
|
|
833
|
+
skipViews?: (string | RegExp)[];
|
|
677
834
|
/**
|
|
678
|
-
*
|
|
679
|
-
* @default
|
|
835
|
+
* Column names or patterns to skip during schema generation, keyed by table name.
|
|
836
|
+
* @default {}
|
|
680
837
|
*/
|
|
681
|
-
|
|
838
|
+
skipColumns?: Dictionary<(string | RegExp)[]>;
|
|
682
839
|
/**
|
|
683
|
-
*
|
|
684
|
-
* @default DefaultLogger.create
|
|
840
|
+
* Database name to use for management operations (e.g., creating/dropping databases).
|
|
685
841
|
*/
|
|
686
|
-
|
|
842
|
+
managementDbName?: string;
|
|
687
843
|
/**
|
|
688
|
-
*
|
|
689
|
-
*
|
|
690
|
-
* Slow query logs are always emitted when the threshold is met, regardless of the `debug` setting.
|
|
691
|
-
* Set to `0` to log every query as slow.
|
|
692
|
-
* @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).
|
|
693
846
|
*/
|
|
694
|
-
|
|
847
|
+
defaultUpdateRule?: 'cascade' | 'no action' | 'set null' | 'set default' | 'restrict';
|
|
695
848
|
/**
|
|
696
|
-
*
|
|
697
|
-
*
|
|
698
|
-
*
|
|
699
|
-
* Note: slow query log entries are emitted with `context.enabled = true` to bypass the
|
|
700
|
-
* debug-mode check. Custom logger implementations must respect `context.enabled` in their
|
|
701
|
-
* `isEnabled()` method (as `DefaultLogger` does) to ensure slow query logs are always emitted.
|
|
702
|
-
* @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).
|
|
703
851
|
*/
|
|
704
|
-
|
|
852
|
+
defaultDeleteRule?: 'cascade' | 'no action' | 'set null' | 'set default' | 'restrict';
|
|
853
|
+
tableSpace?: string;
|
|
854
|
+
};
|
|
855
|
+
/**
|
|
856
|
+
* Embeddable entity configuration options.
|
|
857
|
+
*/
|
|
858
|
+
embeddables: {
|
|
705
859
|
/**
|
|
706
|
-
*
|
|
707
|
-
* @
|
|
708
|
-
* @param where - Query conditions
|
|
709
|
-
* @returns Error instance to throw
|
|
860
|
+
* Mode for generating column prefixes for embedded properties.
|
|
861
|
+
* @default 'relative'
|
|
710
862
|
*/
|
|
711
|
-
|
|
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: {
|
|
712
875
|
/**
|
|
713
|
-
*
|
|
714
|
-
*
|
|
715
|
-
* @param entityName - Name of the entity being queried
|
|
716
|
-
* @param where - Query conditions
|
|
717
|
-
* @returns Error instance to throw
|
|
876
|
+
* Enable metadata caching.
|
|
877
|
+
* Defaults based on the metadata provider's `useCache()` method.
|
|
718
878
|
*/
|
|
719
|
-
|
|
879
|
+
enabled?: boolean;
|
|
720
880
|
/**
|
|
721
|
-
*
|
|
722
|
-
* Can be `true` for
|
|
723
|
-
* Available namespaces: `'query'`, `'query-params'`, `'discovery'`, `'info'`.
|
|
724
|
-
* @default false
|
|
725
|
-
* @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.
|
|
726
883
|
*/
|
|
727
|
-
|
|
884
|
+
combined?: boolean | string;
|
|
728
885
|
/**
|
|
729
|
-
*
|
|
730
|
-
* Can be `true` to ignore all or an array of specific deprecation labels.
|
|
886
|
+
* Pretty print JSON cache files.
|
|
731
887
|
* @default false
|
|
732
|
-
* @see https://mikro-orm.io/docs/logging#deprecation-warnings
|
|
733
888
|
*/
|
|
734
|
-
|
|
889
|
+
pretty?: boolean;
|
|
735
890
|
/**
|
|
736
|
-
*
|
|
737
|
-
* @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.
|
|
738
892
|
*/
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
* Force the ORM to use TypeScript options regardless of detection.
|
|
742
|
-
* Uses `entitiesTs` for discovery and `pathTs` for migrations/seeders.
|
|
743
|
-
* Should only be used for tests, not production builds.
|
|
744
|
-
* @default false
|
|
745
|
-
*/
|
|
746
|
-
preferTs?: boolean;
|
|
747
|
-
/**
|
|
748
|
-
* Base directory for resolving relative paths.
|
|
749
|
-
* @default process.cwd()
|
|
750
|
-
*/
|
|
751
|
-
baseDir: string;
|
|
752
|
-
/**
|
|
753
|
-
* Migration configuration options.
|
|
754
|
-
* @see https://mikro-orm.io/docs/migrations
|
|
755
|
-
*/
|
|
756
|
-
migrations: MigrationsOptions;
|
|
757
|
-
/**
|
|
758
|
-
* Schema generator configuration options.
|
|
759
|
-
*/
|
|
760
|
-
schemaGenerator: {
|
|
761
|
-
/**
|
|
762
|
-
* Try to disable foreign key checks during schema operations.
|
|
763
|
-
* @default false
|
|
764
|
-
*/
|
|
765
|
-
disableForeignKeys?: boolean;
|
|
766
|
-
/**
|
|
767
|
-
* Try to disable foreign key checks during `schema.clear()`. Enabled by default for MySQL/MariaDB.
|
|
768
|
-
*/
|
|
769
|
-
disableForeignKeysForClear?: boolean;
|
|
770
|
-
/**
|
|
771
|
-
* Generate foreign key constraints.
|
|
772
|
-
* @default true
|
|
773
|
-
*/
|
|
774
|
-
createForeignKeyConstraints?: boolean;
|
|
775
|
-
/**
|
|
776
|
-
* Schema names to ignore when comparing schemas.
|
|
777
|
-
* @default []
|
|
778
|
-
*/
|
|
779
|
-
ignoreSchema?: string[];
|
|
780
|
-
/**
|
|
781
|
-
* Table names or patterns to skip during schema generation.
|
|
782
|
-
* @default []
|
|
783
|
-
*/
|
|
784
|
-
skipTables?: (string | RegExp)[];
|
|
785
|
-
/**
|
|
786
|
-
* View names or patterns to skip during schema generation (e.g. PostGIS system views).
|
|
787
|
-
* @default []
|
|
788
|
-
*/
|
|
789
|
-
skipViews?: (string | RegExp)[];
|
|
790
|
-
/**
|
|
791
|
-
* Column names or patterns to skip during schema generation, keyed by table name.
|
|
792
|
-
* @default {}
|
|
793
|
-
*/
|
|
794
|
-
skipColumns?: Dictionary<(string | RegExp)[]>;
|
|
795
|
-
/**
|
|
796
|
-
* Database name to use for management operations (e.g., creating/dropping databases).
|
|
797
|
-
*/
|
|
798
|
-
managementDbName?: string;
|
|
799
|
-
/**
|
|
800
|
-
* Default ON UPDATE rule for foreign keys.
|
|
801
|
-
* When not set, no rule is emitted and the database uses its native default (NO ACTION/RESTRICT).
|
|
802
|
-
*/
|
|
803
|
-
defaultUpdateRule?: 'cascade' | 'no action' | 'set null' | 'set default' | 'restrict';
|
|
804
|
-
/**
|
|
805
|
-
* Default ON DELETE rule for foreign keys.
|
|
806
|
-
* When not set, no rule is emitted and the database uses its native default (NO ACTION/RESTRICT).
|
|
807
|
-
*/
|
|
808
|
-
defaultDeleteRule?: 'cascade' | 'no action' | 'set null' | 'set default' | 'restrict';
|
|
809
|
-
tableSpace?: string;
|
|
810
|
-
};
|
|
811
|
-
/**
|
|
812
|
-
* Embeddable entity configuration options.
|
|
813
|
-
*/
|
|
814
|
-
embeddables: {
|
|
815
|
-
/**
|
|
816
|
-
* Mode for generating column prefixes for embedded properties.
|
|
817
|
-
* @default 'relative'
|
|
818
|
-
*/
|
|
819
|
-
prefixMode: EmbeddedPrefixMode;
|
|
893
|
+
adapter?: {
|
|
894
|
+
new (...params: any[]): SyncCacheAdapter;
|
|
820
895
|
};
|
|
821
896
|
/**
|
|
822
|
-
*
|
|
823
|
-
* @
|
|
897
|
+
* Options passed to the cache adapter constructor.
|
|
898
|
+
* @default { cacheDir: process.cwd() + '/temp' }
|
|
824
899
|
*/
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
/**
|
|
832
|
-
* Enable metadata caching.
|
|
833
|
-
* Defaults based on the metadata provider's `useCache()` method.
|
|
834
|
-
*/
|
|
835
|
-
enabled?: boolean;
|
|
836
|
-
/**
|
|
837
|
-
* Combine all metadata into a single cache file.
|
|
838
|
-
* Can be `true` for default path or a custom path string.
|
|
839
|
-
*/
|
|
840
|
-
combined?: boolean | string;
|
|
841
|
-
/**
|
|
842
|
-
* Pretty print JSON cache files.
|
|
843
|
-
* @default false
|
|
844
|
-
*/
|
|
845
|
-
pretty?: boolean;
|
|
846
|
-
/**
|
|
847
|
-
* 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.
|
|
848
|
-
*/
|
|
849
|
-
adapter?: {
|
|
850
|
-
new (...params: any[]): SyncCacheAdapter;
|
|
851
|
-
};
|
|
852
|
-
/**
|
|
853
|
-
* Options passed to the cache adapter constructor.
|
|
854
|
-
* @default { cacheDir: process.cwd() + '/temp' }
|
|
855
|
-
*/
|
|
856
|
-
options?: Dictionary;
|
|
857
|
-
};
|
|
900
|
+
options?: Dictionary;
|
|
901
|
+
};
|
|
902
|
+
/**
|
|
903
|
+
* Result cache configuration for query result caching.
|
|
904
|
+
*/
|
|
905
|
+
resultCache: {
|
|
858
906
|
/**
|
|
859
|
-
*
|
|
907
|
+
* Default cache expiration time in milliseconds.
|
|
908
|
+
* @default 1000
|
|
860
909
|
*/
|
|
861
|
-
|
|
862
|
-
/**
|
|
863
|
-
* Default cache expiration time in milliseconds.
|
|
864
|
-
* @default 1000
|
|
865
|
-
*/
|
|
866
|
-
expiration?: number;
|
|
867
|
-
/**
|
|
868
|
-
* Cache adapter class to use.
|
|
869
|
-
* @default MemoryCacheAdapter
|
|
870
|
-
*/
|
|
871
|
-
adapter?: {
|
|
872
|
-
new (...params: any[]): CacheAdapter;
|
|
873
|
-
};
|
|
874
|
-
/**
|
|
875
|
-
* Options passed to the cache adapter constructor.
|
|
876
|
-
* @default {}
|
|
877
|
-
*/
|
|
878
|
-
options?: Dictionary;
|
|
879
|
-
/**
|
|
880
|
-
* Enable global result caching for all queries.
|
|
881
|
-
* Can be `true`, an expiration number, or a tuple of `[key, expiration]`.
|
|
882
|
-
*/
|
|
883
|
-
global?: boolean | number | [string, number];
|
|
884
|
-
};
|
|
910
|
+
expiration?: number;
|
|
885
911
|
/**
|
|
886
|
-
*
|
|
887
|
-
*
|
|
888
|
-
* @default ReflectMetadataProvider
|
|
889
|
-
* @see https://mikro-orm.io/docs/metadata-providers
|
|
912
|
+
* Cache adapter class to use.
|
|
913
|
+
* @default MemoryCacheAdapter
|
|
890
914
|
*/
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
useCache?: MetadataProvider['useCache'];
|
|
915
|
+
adapter?: {
|
|
916
|
+
new (...params: any[]): CacheAdapter;
|
|
894
917
|
};
|
|
895
918
|
/**
|
|
896
|
-
*
|
|
897
|
-
* @
|
|
898
|
-
*/
|
|
899
|
-
|
|
900
|
-
/**
|
|
901
|
-
*
|
|
902
|
-
*
|
|
903
|
-
*/
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
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>;
|
|
910
954
|
}
|