Skip to main content
Version: 4.5

Class: MikroORM<D>#

core.MikroORM

Helper class for bootstrapping the MikroORM.

Type parameters#

NameTypeDefault
DIDatabaseDriverIDatabaseDriver

Constructors#

constructor#

+ new MikroORM<D>(options: Options<D> | Configuration<D>): MikroORM<D>

Type parameters:#

NameTypeDefault
DIDatabaseDriver<Connection, D>IDatabaseDriver<Connection>

Parameters:#

NameType
optionsOptions<D> | Configuration<D>

Returns: MikroORM<D>

Defined in: packages/core/src/MikroORM.ts:50

Properties#

config#

Readonly config: Configuration<D>

Defined in: packages/core/src/MikroORM.ts:16


driver#

Private Readonly driver: D

Defined in: packages/core/src/MikroORM.ts:18


em#

em: D[typeof EntityManagerType] & EntityManager<IDatabaseDriver<Connection>>

Defined in: packages/core/src/MikroORM.ts:15


logger#

Private Readonly logger: Logger

Defined in: packages/core/src/MikroORM.ts:19


metadata#

Private metadata: MetadataStorage

Defined in: packages/core/src/MikroORM.ts:17

Methods#

close#

close(force?: boolean): Promise<void>

Closes the database connection.

Parameters:#

NameTypeDefault value
forcebooleanfalse

Returns: Promise<void>

Defined in: packages/core/src/MikroORM.ts:97


connect#

connect(): Promise<D>

Connects to the database.

Returns: Promise<D>

Defined in: packages/core/src/MikroORM.ts:72


getEntityGenerator#

getEntityGenerator<T>(): T

Gets the EntityGenerator.

Type parameters:#

NameTypeDefault
TIEntityGeneratorIEntityGenerator

Returns: T

Defined in: packages/core/src/MikroORM.ts:118


getMetadata#

getMetadata(): MetadataStorage

Gets the MetadataStorage.

Returns: MetadataStorage

Defined in: packages/core/src/MikroORM.ts:104


getMigrator#

getMigrator<T>(): T

Gets the Migrator.

Type parameters:#

NameTypeDefault
TIMigratorIMigrator

Returns: T

Defined in: packages/core/src/MikroORM.ts:127


getSchemaGenerator#

getSchemaGenerator<T>(): T

Gets the SchemaGenerator.

Type parameters:#

NameTypeDefault
TISchemaGeneratorISchemaGenerator

Returns: T

Defined in: packages/core/src/MikroORM.ts:111


isConnected#

isConnected(): Promise<boolean>

Checks whether the database connection is active.

Returns: Promise<boolean>

Defined in: packages/core/src/MikroORM.ts:90


init#

Staticinit<D>(options?: Options<D> | Configuration<D>, connect?: boolean): Promise<MikroORM<D>>

Initialize the ORM, load entity metadata, create EntityManager and connect to the database. If you omit the options parameter, your CLI config will be used.

Type parameters:#

NameTypeDefault
DIDatabaseDriver<Connection, D>IDatabaseDriver<Connection>

Parameters:#

NameTypeDefault value
options?Options<D> | Configuration<D>-
connectbooleantrue

Returns: Promise<MikroORM<D>>

Defined in: packages/core/src/MikroORM.ts:25

Last updated on by Martin Adámek