Skip to main content
Version: 5.9

MikroORM

Helper class for bootstrapping the MikroORM.

Hierarchy

Index

Constructors

constructor

Properties

readonlyconfig

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

close

  • close(force): 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>

discoverEntity

  • discoverEntity(entities): Promise<void>
  • Allows dynamically discovering new entity by reference, handy for testing schema diffing.


    Parameters

    Returns Promise<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): Promise<void>
  • Reconnects, possibly to a different database.


    Parameters

    Returns Promise<void>

staticinit

  • init<D>(options, connect): Promise<MikroORM<D>>
  • 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

    Parameters

    Returns Promise<MikroORM<D>>