ποΈ Defining Entities
Entities are simple javascript objects (so called POJO) without restrictions and without the need to extend base classes. Using entity constructors works as well - they are never executed for managed entities (loaded from database). Every entity is required to have a primary key.
ποΈ Modeling Entity Relationships
There are 4 types of entity relationships in MikroORM:
ποΈ Entity Manager
Persist and Flush
ποΈ Updating Entity Values
Updating Entity Values with assign()
ποΈ Unit of Work
MikroORM uses the Identity Map pattern to track objects. Whenever you fetch an object from the database, MikroORM will keep a reference to this object inside its UnitOfWork.
ποΈ Identity Map
MikroORM uses identity map in background, so we will always get the same instance of one entity.
ποΈ Collections
OneToMany and ManyToMany properties are stored in a Collection wrapper.
ποΈ Query Conditions
When you want to make complex queries, we can easily end up with a lot of boilerplate code full of curly brackets:
ποΈ Populating relations
MikroORM is capable of loading large nested structures while maintaining good performance, querying each database table only once. Imagine you have this nested structure:
ποΈ 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.
ποΈ Transactions and Concurrency
Starting v3.4, transactions are also supported in MongoDB driver.
ποΈ Entity Repository
Entity Repositories are thin layers on top of EntityManager. They act as an extension point, so you can add custom methods, or even alter the existing ones. The default EntityRepository implementation just forwards the calls to underlying EntityManager instance.
ποΈ Inheritance Mapping
Mapped Superclasses
ποΈ Cascading
From v4.2, cascade merging is no longer configurable (and is kept enabled for all relations).
ποΈ Query Builder
Since v4, we need to make sure we are working with correctly typed EntityManager or EntityRepository to have access to createQueryBuilder() method.
ποΈ Using raw SQL query fragments
raw() helper