📄️ Identity Map
MikroORM uses identity map in background, so we will always get the same instance of one entity.
OneToMany and ManyToMany properties are stored in a Collection wrapper.
📄️ Type-Safe Relations
Entity relations are mapped to entity references - instances of the entity that have at least the primary key available. This reference is stored in identity map, so you will get the same object reference when fetching the same document from database.
📄️ Entity Repository
Entity Repositories are thin layers on top of EntityManager. They act as an extension point, so we can add custom methods, or even alter the existing ones. The default, EntityRepository implementation just forwards the calls to underlying EntityManager instance.
📄️ Transactions and Concurrency
Starting v3.4, transactions are also supported in MongoDB driver.
📄️ Inheritance Mapping
From v4.2, cascade merging is no longer configurable (and is kept enabled for all relations).
MikroORM has the ability to pre-define filter criteria and attach those filters to given entities. The application can then decide at runtime whether certain filters should be enabled and what their parameter values should be. Filters can be used like database views, but they are parameterized inside the application.
Under the hood, MikroORM uses ts-morph to read TypeScript source files of all entities to be able to detect all types. Thanks to this, defining the type is enough for runtime validation.
📄️ Using Query Builder
When you need to execute some SQL query without all the ORM stuff involved, you can either compose the query yourself, or use the QueryBuilder helper to construct the query for you:
📄️ Result cache
MikroORM has simple result caching mechanism. It works with those methods of EntityManager: find(), findOne(), findAndCount(), findOneOrFail(), count(), as well as with QueryBuilder result methods (including execute).
For development purposes it might come handy to enable logging and debug mode: