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