Skip to main content
Version: 6.4

MikroORM <EM>

Helper class for bootstrapping the MikroORM.

Hierarchy

Index

Constructors

constructor

Properties

readonlyinheritedconfig

inheritedem

em: EM

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

Accessors

inheritedentityGenerator

  • Shortcut for orm.getEntityGenerator()


    Returns IEntityGenerator

inheritedmigrator

  • Shortcut for orm.getMigrator()


    Returns IMigrator

inheritedschema

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


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

inheritedseeder

  • Shortcut for orm.getSeeder()


    Returns ISeedManager

Methods

inheritedcheckConnection

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

inheritedclose

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


    Parameters

    • force: boolean = false

    Returns Promise<void>

inheritedconnect

  • Connects to the database.


    Returns Promise<MySqlDriver>

inheriteddiscoverEntities

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

inheriteddiscoverEntitiesSync

  • discoverEntitiesSync(): void
  • Returns void

inheriteddiscoverEntity

  • 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

inheritedgetEntityGenerator

  • getEntityGenerator(): T
  • Gets the EntityGenerator.


    Returns T

inheritedgetMetadata

  • Gets the MetadataStorage.


    Returns MetadataStorage

inheritedgetMigrator

  • getMigrator(): T
  • Gets the Migrator.


    Returns T

inheritedgetSchemaGenerator

  • Gets the SchemaGenerator.


    Returns SqlSchemaGenerator

inheritedgetSeeder

  • getSeeder(): T
  • Gets the SeedManager


    Returns T

inheritedisConnected

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


    Returns Promise<boolean>

inheritedreconnect

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