MikroORM <EM>
Hierarchy
- MikroORM<MongoDriver, EM>
- MikroORM
Index
Constructors
constructor
Type parameters
Parameters
options: Options<MongoDriver, EM> | Configuration<MongoDriver, EM>
Returns MongoMikroORM<EM>
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
Shortcut for
orm.getSchemaGenerator()
Returns ReturnType<ReturnType<D[getPlatform]>[getSchemaGenerator]>
seeder
Shortcut for
orm.getSeeder()
Returns ISeedManager
Methods
checkConnection
Checks whether the database connection is active, returns .
Returns Promise<{ error?: Error; ok: boolean; reason?: string }>
close
Closes the database connection.
Parameters
force: boolean = false
Returns Promise<void>
connect
Connects to the database.
Returns Promise<MongoDriver>
discoverEntities
Returns Promise<void>
discoverEntitiesSync
Returns void
discoverEntity
Allows dynamically discovering new entity by reference, handy for testing schema diffing.
Type parameters
- T: EntitySchema<any, never> | Constructor
Parameters
entities: T | T[]
optionalreset: string | string[]
Returns void
getEntityGenerator
Gets the EntityGenerator.
Type parameters
Returns T
getMetadata
Gets the
MetadataStorage
.Returns MetadataStorage
getMigrator
getSchemaGenerator
Gets the SchemaGenerator.
Returns MongoSchemaGenerator
getSeeder
Gets the SeedManager
Type parameters
- T: ISeedManager = ISeedManager
Returns T
isConnected
Checks whether the database connection is active.
Returns Promise<boolean>
reconnect
Reconnects, possibly to a different database.
Parameters
options: Options = {}
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.Type parameters
- D: IDatabaseDriver<Connection> = MongoDriver
- EM: EntityManager<IDatabaseDriver<Connection>> = D[typeof EntityManagerType] & EntityManager<IDatabaseDriver<Connection>>
Parameters
optionaloptions: Options<D, EM>
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
Type parameters
- D: IDatabaseDriver<Connection> = MongoDriver
- EM: EntityManager<IDatabaseDriver<Connection>> = D[typeof EntityManagerType] & EntityManager<IDatabaseDriver<Connection>>
Parameters
options: Options<D, EM>
Returns MikroORM<D, EM>
- database connection will be established when you first interact with the database (or you can use
Helper class for bootstrapping the MikroORM.