Skip to main content
Version: 4.4

Class: Configuration<D>#

core.Configuration

Type parameters#

NameTypeDefault
DIDatabaseDriverIDatabaseDriver

Hierarchy#

  • Configuration

Constructors#

constructor#

+ new Configuration<D>(options: Options<IDatabaseDriver<Connection>>, validate?: boolean): Configuration<D>

Type parameters:#

NameTypeDefault
DIDatabaseDriver<Connection, D>IDatabaseDriver<Connection\>

Parameters:#

NameTypeDefault value
optionsOptions<IDatabaseDriver<Connection>>-
validatebooleantrue

Returns: Configuration<D>

Defined in: packages/core/src/utils/Configuration.ts:98

Properties#

cache#

Private Readonly cache: Dictionary<any>

Defined in: packages/core/src/utils/Configuration.ts:98


driver#

Private Readonly driver: D

Defined in: packages/core/src/utils/Configuration.ts:96


logger#

Private Readonly logger: Logger

Defined in: packages/core/src/utils/Configuration.ts:95


options#

Private Readonly options: MikroORMOptions<D>

Defined in: packages/core/src/utils/Configuration.ts:94


platform#

Private Readonly platform: Platform

Defined in: packages/core/src/utils/Configuration.ts:97


DEFAULTS#

Readonly Static DEFAULTS: { autoJoinOneToOneOwner: boolean = true; baseDir: string ; batchSize: number = 300; cache: { adapter: typeof FileCacheAdapter ; options: { cacheDir: string } ; pretty: boolean = false } ; context: (name: string) => undefined | EntityManager<IDatabaseDriver<Connection>> ; contextName: string = 'default'; debug: boolean = false; discovery: { alwaysAnalyseProperties: boolean = true; disableDynamicFileAccess: boolean = false; requireEntitiesArray: boolean = false; warnWhenNoEntities: boolean = true } ; driverOptions: {} ; ensureIndexes: boolean = false; entities: never[] ; entitiesTs: never[] ; filters: {} ; findOneOrFailHandler: (entityName: string, where: string | number | bigint | Date | { toHexString: () => string } | Dictionary<any>) => NotFoundError<AnyEntity<any>> ; forceEntityConstructor: boolean = false; forceUndefined: boolean = false; forceUtcTimezone: boolean = false; highlighter: NullHighlighter ; hydrator: typeof ObjectHydrator ; loadStrategy: LoadStrategy ; logger: (...data: any[]) => void(message?: any, ...optionalParams: any[]) => void ; metadataProvider: typeof ReflectMetadataProvider ; migrations: { allOrNothing: boolean = true; disableForeignKeys: boolean = true; dropTables: boolean = true; emit: string = 'ts'; fileName: (timestamp: string) => string ; path: string = './migrations'; pattern: RegExp ; safe: boolean = false; tableName: string = 'mikro_orm_migrations'; transactional: boolean = true } ; pool: {} ; populateAfterFlush: boolean = false; propagateToOneOwner: boolean = true; resultCache: { adapter: typeof MemoryCacheAdapter ; expiration: number = 1000; options: {} } ; strict: boolean = false; subscribers: never[] ; validate: boolean = false; verbose: boolean = false }

Type declaration:#

NameType
autoJoinOneToOneOwnerboolean
baseDirstring
batchSizenumber
cache{ adapter: typeof FileCacheAdapter ; options: { cacheDir: string } ; pretty: boolean = false }
context(name: string) => undefined | EntityManager<IDatabaseDriver<Connection>>
contextNamestring
debugboolean
discovery{ alwaysAnalyseProperties: boolean = true; disableDynamicFileAccess: boolean = false; requireEntitiesArray: boolean = false; warnWhenNoEntities: boolean = true }
driverOptions{}
ensureIndexesboolean
entitiesnever[]
entitiesTsnever[]
filters{}
findOneOrFailHandler(entityName: string, where: string | number | bigint | Date | { toHexString: () => string } | Dictionary<any>) => NotFoundError<AnyEntity<any>>
forceEntityConstructorboolean
forceUndefinedboolean
forceUtcTimezoneboolean
highlighterNullHighlighter
hydratortypeof ObjectHydrator
loadStrategyLoadStrategy
logger(...data: any[]) => void(message?: any, ...optionalParams: any[]) => void
metadataProvidertypeof ReflectMetadataProvider
migrations{ allOrNothing: boolean = true; disableForeignKeys: boolean = true; dropTables: boolean = true; emit: string = 'ts'; fileName: (timestamp: string) => string ; path: string = './migrations'; pattern: RegExp ; safe: boolean = false; tableName: string = 'mikro_orm_migrations'; transactional: boolean = true }
pool{}
populateAfterFlushboolean
propagateToOneOwnerboolean
resultCache{ adapter: typeof MemoryCacheAdapter ; expiration: number = 1000; options: {} }
strictboolean
subscribersnever[]
validateboolean
verboseboolean

Defined in: packages/core/src/utils/Configuration.ts:27


PLATFORMS#

Readonly Static PLATFORMS: { mariadb: { className: string = 'MariaDbDriver'; module: () => any } ; mongo: { className: string = 'MongoDriver'; module: () => any } ; mysql: { className: string = 'MySqlDriver'; module: () => any } ; postgresql: { className: string = 'PostgreSqlDriver'; module: () => any } ; sqlite: { className: string = 'SqliteDriver'; module: () => any } }

Type declaration:#

NameType
mariadb{ className: string = 'MariaDbDriver'; module: () => any }
mongo{ className: string = 'MongoDriver'; module: () => any }
mysql{ className: string = 'MySqlDriver'; module: () => any }
postgresql{ className: string = 'PostgreSqlDriver'; module: () => any }
sqlite{ className: string = 'SqliteDriver'; module: () => any }

Defined in: packages/core/src/utils/Configuration.ts:86

Methods#

cached#

Privatecached<T>(cls: T, ...args: ConstructorParameters<T>): InstanceType<T>

Type parameters:#

NameType
T(...args: any[]) => InstanceType<T>

Parameters:#

NameType
clsT
...argsConstructorParameters<T>

Returns: InstanceType<T>

Defined in: packages/core/src/utils/Configuration.ts:269


get#

get<T, U>(key: T, defaultValue?: U): U

Gets specific configuration option. Falls back to specified defaultValue if provided.

Type parameters:#

NameType
Tname | type | entities | entitiesTs | subscribers | filters | discovery | driver | driverOptions | namingStrategy | implicitTransactions | autoJoinOneToOneOwner | propagateToOneOwner | populateAfterFlush | forceEntityConstructor | forceUndefined | forceUtcTimezone | timezone | ensureIndexes | useBatchInserts | useBatchUpdates | batchSize | hydrator | loadStrategy | entityRepository | replicas | strict | validate | context | contextName | logger | findOneOrFailHandler | debug | highlighter | tsNode | baseDir | migrations | cache | resultCache | metadataProvider | dbName | clientUrl | host | port | user | password | charset | collate | multipleStatements | pool
Uundefined | string | number | boolean | Dictionary<any> | Highlighter | () => NamingStrategy | Constructor<EntityRepository<any>> | Partial<ConnectionOptions>[] | (string | EntityClass<AnyEntity<any>> | EntityClassGroup<AnyEntity<any>> | EntitySchema<any, undefined>)[] | EventSubscriber<any>[] | Dictionary<{ name?: undefined | string } & Pick<FilterDef<AnyEntity<any>>, default | entity | cond | args>> | { alwaysAnalyseProperties?: undefined | boolean ; disableDynamicFileAccess?: undefined | boolean ; requireEntitiesArray?: undefined | boolean ; warnWhenNoEntities?: undefined | boolean } | (config: Configuration<IDatabaseDriver<Connection>>) => D | (string | Constructor<AnyEntity<any>>)[] | HydratorConstructor | (name: string) => undefined | EntityManager<IDatabaseDriver<Connection>> | (message: string) => void | (entityName: string, where: string | number | bigint | Date | { toHexString: () => string } | Dictionary<any>) => Error | LoggerNamespace[] | MigrationsOptions | { adapter?: undefined | (...params: any[]) => CacheAdapter ; enabled?: undefined | boolean ; options?: undefined | Dictionary<any> ; pretty?: undefined | boolean } | { adapter?: undefined | (...params: any[]) => CacheAdapter ; expiration?: undefined | number ; options?: undefined | Dictionary<any> } | (config: Configuration<IDatabaseDriver<Connection>>) => MetadataProvider | PoolConfig

Parameters:#

NameType
keyT
defaultValue?U

Returns: U

Defined in: packages/core/src/utils/Configuration.ts:118


getCacheAdapter#

getCacheAdapter(): CacheAdapter

Gets instance of CacheAdapter. (cached)

Returns: CacheAdapter

Defined in: packages/core/src/utils/Configuration.ts:185


getClientUrl#

getClientUrl(hidePassword?: boolean): string

Gets current client URL (connection string).

Parameters:#

NameTypeDefault value
hidePasswordbooleanfalse

Returns: string

Defined in: packages/core/src/utils/Configuration.ts:146


getDriver#

getDriver(): D

Gets current database driver instance.

Returns: D

Defined in: packages/core/src/utils/Configuration.ts:157


getHydrator#

getHydrator(metadata: MetadataStorage): IHydrator

Gets instance of Hydrator.

Parameters:#

NameType
metadataMetadataStorage

Returns: IHydrator

Defined in: packages/core/src/utils/Configuration.ts:171


getLogger#

getLogger(): Logger

Gets Logger instance.

Returns: Logger

Defined in: packages/core/src/utils/Configuration.ts:139


getMetadataProvider#

getMetadataProvider(): MetadataProvider

Gets instance of MetadataProvider. (cached)

Returns: MetadataProvider

Defined in: packages/core/src/utils/Configuration.ts:178


getNamingStrategy#

getNamingStrategy(): NamingStrategy

Gets instance of NamingStrategy. (cached)

Returns: NamingStrategy

Defined in: packages/core/src/utils/Configuration.ts:164


getRepositoryClass#

getRepositoryClass(customRepository: undefined | () => Constructor<EntityRepository<any>>): undefined | Constructor<EntityRepository<any>>

Gets EntityRepository class to be instantiated.

Parameters:#

NameType
customRepositoryundefined | () => Constructor<EntityRepository<any>>

Returns: undefined | Constructor<EntityRepository<any>>

Defined in: packages/core/src/utils/Configuration.ts:199


getResultCacheAdapter#

getResultCacheAdapter(): CacheAdapter

Gets instance of CacheAdapter for result cache. (cached)

Returns: CacheAdapter

Defined in: packages/core/src/utils/Configuration.ts:192


init#

Privateinit(): void

Returns: void

Defined in: packages/core/src/utils/Configuration.ts:211


initDriver#

PrivateinitDriver(): D

Returns: D

Defined in: packages/core/src/utils/Configuration.ts:260


reset#

reset<T, U>(key: T): void

Resets the configuration to its default value

Type parameters:#

NameType
Tname | type | entities | entitiesTs | subscribers | filters | discovery | driver | driverOptions | namingStrategy | implicitTransactions | autoJoinOneToOneOwner | propagateToOneOwner | populateAfterFlush | forceEntityConstructor | forceUndefined | forceUtcTimezone | timezone | ensureIndexes | useBatchInserts | useBatchUpdates | batchSize | hydrator | loadStrategy | entityRepository | replicas | strict | validate | context | contextName | logger | findOneOrFailHandler | debug | highlighter | tsNode | baseDir | migrations | cache | resultCache | metadataProvider | dbName | clientUrl | host | port | user | password | charset | collate | multipleStatements | pool
Uundefined | string | number | boolean | Dictionary<any> | Highlighter | () => NamingStrategy | Constructor<EntityRepository<any>> | Partial<ConnectionOptions>[] | (string | EntityClass<AnyEntity<any>> | EntityClassGroup<AnyEntity<any>> | EntitySchema<any, undefined>)[] | EventSubscriber<any>[] | Dictionary<{ name?: undefined | string } & Pick<FilterDef<AnyEntity<any>>, default | entity | cond | args>> | { alwaysAnalyseProperties?: undefined | boolean ; disableDynamicFileAccess?: undefined | boolean ; requireEntitiesArray?: undefined | boolean ; warnWhenNoEntities?: undefined | boolean } | (config: Configuration<IDatabaseDriver<Connection>>) => D | (string | Constructor<AnyEntity<any>>)[] | HydratorConstructor | (name: string) => undefined | EntityManager<IDatabaseDriver<Connection>> | (message: string) => void | (entityName: string, where: string | number | bigint | Date | { toHexString: () => string } | Dictionary<any>) => Error | LoggerNamespace[] | MigrationsOptions | { adapter?: undefined | (...params: any[]) => CacheAdapter ; enabled?: undefined | boolean ; options?: undefined | Dictionary<any> ; pretty?: undefined | boolean } | { adapter?: undefined | (...params: any[]) => CacheAdapter ; expiration?: undefined | number ; options?: undefined | Dictionary<any> } | (config: Configuration<IDatabaseDriver<Connection>>) => MetadataProvider | PoolConfig

Parameters:#

NameType
keyT

Returns: void

Defined in: packages/core/src/utils/Configuration.ts:132


set#

set<T, U>(key: T, value: U): void

Overrides specified configuration value.

Type parameters:#

NameType
Tname | type | entities | entitiesTs | subscribers | filters | discovery | driver | driverOptions | namingStrategy | implicitTransactions | autoJoinOneToOneOwner | propagateToOneOwner | populateAfterFlush | forceEntityConstructor | forceUndefined | forceUtcTimezone | timezone | ensureIndexes | useBatchInserts | useBatchUpdates | batchSize | hydrator | loadStrategy | entityRepository | replicas | strict | validate | context | contextName | logger | findOneOrFailHandler | debug | highlighter | tsNode | baseDir | migrations | cache | resultCache | metadataProvider | dbName | clientUrl | host | port | user | password | charset | collate | multipleStatements | pool
Uundefined | string | number | boolean | Dictionary<any> | Highlighter | () => NamingStrategy | Constructor<EntityRepository<any>> | Partial<ConnectionOptions>[] | (string | EntityClass<AnyEntity<any>> | EntityClassGroup<AnyEntity<any>> | EntitySchema<any, undefined>)[] | EventSubscriber<any>[] | Dictionary<{ name?: undefined | string } & Pick<FilterDef<AnyEntity<any>>, default | entity | cond | args>> | { alwaysAnalyseProperties?: undefined | boolean ; disableDynamicFileAccess?: undefined | boolean ; requireEntitiesArray?: undefined | boolean ; warnWhenNoEntities?: undefined | boolean } | (config: Configuration<IDatabaseDriver<Connection>>) => D | (string | Constructor<AnyEntity<any>>)[] | HydratorConstructor | (name: string) => undefined | EntityManager<IDatabaseDriver<Connection>> | (message: string) => void | (entityName: string, where: string | number | bigint | Date | { toHexString: () => string } | Dictionary<any>) => Error | LoggerNamespace[] | MigrationsOptions | { adapter?: undefined | (...params: any[]) => CacheAdapter ; enabled?: undefined | boolean ; options?: undefined | Dictionary<any> ; pretty?: undefined | boolean } | { adapter?: undefined | (...params: any[]) => CacheAdapter ; expiration?: undefined | number ; options?: undefined | Dictionary<any> } | (config: Configuration<IDatabaseDriver<Connection>>) => MetadataProvider | PoolConfig

Parameters:#

NameType
keyT
valueU

Returns: void

Defined in: packages/core/src/utils/Configuration.ts:125


validateOptions#

PrivatevalidateOptions(): void

Returns: void

Defined in: packages/core/src/utils/Configuration.ts:246

Last updated on by renovate[bot]