Skip to main content
Version: 6.4

MikroORM <D, 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

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

Methods

checkConnection

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


    Returns Promise<{ ok: true } | { error?: Error; ok: false; reason: string }>

close

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


    Parameters

    • force: boolean = false

    Returns Promise<void>

connect

  • connect(): Promise<D>
  • Connects to the database.


    Returns Promise<D>

discoverEntities

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

discoverEntitiesSync

  • discoverEntitiesSync(): void
  • Returns void

discoverEntity

  • discoverEntity(entities: T | T[], reset?: string | string[]): void
  • Allows dynamically discovering new entity by reference, handy for testing schema diffing.


    Parameters

    • entities: T | T[]
    • optionalreset: string | string[]

    Returns void

getEntityGenerator

  • getEntityGenerator(): T
  • Gets the EntityGenerator.


    Returns T

getMetadata

getMigrator

  • getMigrator(): T
  • Gets the Migrator.


    Returns T

getSchemaGenerator

  • getSchemaGenerator(): ReturnType<ReturnType<D[getPlatform]>[getSchemaGenerator]>
  • Gets the SchemaGenerator.


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

getSeeder

  • getSeeder(): T
  • Gets the SeedManager


    Returns 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

  • 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.


    Parameters

    Returns Promise<MikroORM<D, EM>>

staticinitSync

  • Synchronous variant of the init method with some limitations:

    • database connection will be established when you first interact with the database (or you can use orm.connect() explicitly)
    • no loading of the config file, options parameter is mandatory
    • no support for folder based discovery
    • no check for mismatched package versions

    Parameters

    Returns MikroORM<D, EM>