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