You can either provide array of entity instances via
entities, or let the ORM look up your
entities in selected folders.
entitiesDirs, you can optionally provide also set of directories with TS source files,
that will be used to look up missing types (see more at Metadata Providers).
entitiesDirsTsoption is used only with the default
TsMorphMetadataProvider. By default, all your source files will be scanned, based on your
TsMorphMetadataProvider is used that analyses your entity source files. You can
ReflectMetadataProvider if you do not want the source file analyses to happen.
You can also implement your own metadata provider and use it instead. To do so, extend the
There are also some additional options how you can adjust the discovery process:
If you disable
discovery.alwaysAnalysePropertiesoption, you will need to explicitly provide
wrappedReferenceparameters (where applicable).
Read more about this in Metadata Providers sections.
To select driver, you can either use
type option, or provide the driver class reference.
|compatible with MariaDB|
|compatible with MySQL|
Driver and connection implementations are not directly exported from
mikro-ormmodule. You can import them from
You can pass additional options to the underlying driver (e.g.
driverOptions. The object will be deeply merged, overriding all internally used options.
Each platform (driver) provides default connection string, you can override it as a whole
clientUrl, or partially through one of following options:
Following table shows default client connection strings:
|type||default connection url|
To set up read replicas, you can use
replicas option. You can provide only those parts of the
ConnectionOptions interface, they will be used to override the
master connection options.
Since MikroORM v3, default value for
false. That means you need to call
em.flush() yourself to persist changes into database. You can still change this via ORM's
options to ease the transition but generally it is not recommended as it can cause unwanted
small transactions being created around each
Read more about this in Entity Manager docs.
When mapping your entities to database tables and columns, their names will be defined by naming strategy. There are 3 basic naming strategies you can choose from:
UnderscoreNamingStrategy- default of all SQL drivers
MongoNamingStrategy- default of
EntityCaseNamingStrategy- uses unchanged entity and property names
You can also define your own custom
Read more about this in Naming Strategy section.
Auto-join of 1:1 owners
By default, owning side of 1:1 relation will be auto-joined when you select the inverse side
so we can have the reference to it. You can disable this behaviour via
Propagation of 1:1 and m:1 owners
MikroORM defines getter and setter for every owning side of m:1 and 1:1 relation. This is then used for propagation of changes to the inverse side of bi-directional relations.
You can disable this behaviour via
Forcing UTC Timezone
forceUtcTimezone option to force the
Dates to be saved in UTC in datetime columns
without timezone. It works for MySQL (
datetime type) and PostgreSQL (
SQLite does this by default.
Hydrator is responsible for assigning values from the database to entities.
You can implement your custom
Hydrator (by extending the abstract
You can also register custom base repository (for all entities where you do not specify
You can still use entity specific repositories in combination with global base repository.
Read more about this in Repositories section.
MirkoORM will validate your properties before actual persisting happens. It will try to fix wrong
data types for you automatically. If automatic conversion fails, it will throw an error. You can
enable strict mode to disable this feature and let ORM throw errors instead. Validation is triggered
when persisting the entity.
Read more about this in Property Validation section.
Debugging & Logging
You can enable logging with
debug option. Either set it to
true to log everything, or
provide array of
'query' | 'query-params' | 'discovery' | 'info' namespaces.
Read more about this in Debugging section.
Custom Fail Handler
When no entity is found during
new Error() will be thrown.
You can customize how the
Error instance is created via
Read more about this in Entity Manager docs.
migrations namespace, you can adjust how the integrated migrations support works.
Following example shows all possible options and their defaults:
Read more about this in Migrations section.
By default, metadata discovery results are cached. You can either disable caching, or adjust how it works. Following example shows all possible options and their defaults:
Read more about this in Metadata Cache section.