Skip to main content
Version: 6.1

MikroORM <EM>

Helper class for bootstrapping the MikroORM.

Hierarchy

Index

Constructors

constructor

Properties

readonlyconfig

em

em: EM

The global EntityManager instance. If you are using RequestContext helper, it will automatically pick the request specific context under the hood

Accessors

entityGenerator

  • Shortcut for orm.getEntityGenerator()


    Returns IEntityGenerator

migrator

  • Shortcut for orm.getMigrator()


    Returns IMigrator

schema

  • get schema(): ReturnType<ReturnType<D[getPlatform]>[getSchemaGenerator]>
  • Shortcut for orm.getSchemaGenerator()


    Returns ReturnType<ReturnType<D[getPlatform]>[getSchemaGenerator]>

seeder

  • Shortcut for orm.getSeeder()


    Returns ISeedManager

Methods

checkConnection

  • checkConnection(): Promise<{ error?: Error; ok: boolean; reason?: string }>
  • Checks whether the database connection is active, returns .


    Returns Promise<{ error?: Error; ok: boolean; reason?: string }>

close

  • close(force?: boolean): Promise<void>
  • Closes the database connection.


    Parameters

    • force: boolean = false

    Returns Promise<void>

connect

  • Connects to the database.


    Returns Promise<SqliteDriver>

discoverEntities

  • discoverEntities(): Promise<void>
  • Returns Promise<void>

discoverEntitiesSync

  • discoverEntitiesSync(): void
  • Returns void

discoverEntity

  • Allows dynamically discovering new entity by reference, handy for testing schema diffing.


    Parameters

    Returns void

getEntityGenerator

  • getEntityGenerator<T>(): T

getMetadata

  • Gets the MetadataStorage.


    Returns MetadataStorage

getMigrator

  • getMigrator<T>(): T
  • Gets the Migrator.


    Type parameters

    Returns T

getSchemaGenerator

  • Gets the SchemaGenerator.


    Returns SqlSchemaGenerator

getSeeder

  • getSeeder<T>(): T

isConnected

  • isConnected(): Promise<boolean>
  • Checks whether the database connection is active.


    Returns Promise<boolean>

reconnect

  • reconnect(options?: Options): Promise<void>
  • Reconnects, possibly to a different database.


    Parameters

    Returns Promise<void>

staticinit

staticinitSync