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