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