Version: 4.3

Class: MikroORM<D>

Helper class for bootstrapping the MikroORM.

Type parameters

NameTypeDefault
DIDatabaseDriverIDatabaseDriver

Hierarchy

  • MikroORM

Constructors

constructor

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

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

Parameters:

NameType
optionsOptions<D> | Configuration<D>

Returns: MikroORM

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

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>

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

Closes the database connection.

Parameters:

NameTypeDefault value
forcebooleanfalse

Returns: Promise<void>


connect

connect(): Promise<D>

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

Connects to the database.

Returns: Promise<D>


getEntityGenerator

getEntityGenerator<T>(): T

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

Gets the EntityGenerator.

Type parameters:

NameTypeDefault
TIEntityGeneratorIEntityGenerator

Returns: T


getMetadata

getMetadata(): MetadataStorage

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

Gets the MetadataStorage.

Returns: MetadataStorage


getMigrator

getMigrator<T>(): T

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

Gets the Migrator.

Type parameters:

NameTypeDefault
TIMigratorIMigrator

Returns: T


getSchemaGenerator

getSchemaGenerator<T>(): T

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

Gets the SchemaGenerator.

Type parameters:

NameTypeDefault
TISchemaGeneratorISchemaGenerator

Returns: T


isConnected

isConnected(): Promise<boolean>

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

Checks whether the database connection is active.

Returns: Promise<boolean>


init

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

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

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
DIDatabaseDriverIDatabaseDriver

Parameters:

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

Returns: Promise<MikroORM<D>>

Last updated on by Martin Adámek