Skip to main content
Version: Next

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<MongoDriver>

discoverEntities

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

discoverEntitiesSync

  • discoverEntitiesSync(): void
  • Returns void

discoverEntity

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


    Type parameters

    Parameters

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

    Returns void

getEntityGenerator

  • getEntityGenerator<T>(): T

getMetadata

  • Gets the MetadataStorage.


    Returns MetadataStorage

getMigrator

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


    Type parameters

    Returns T

getSchemaGenerator

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