Please enable JavaScript.
Coggle requires JavaScript to display documents.
MicroORM - Coggle Diagram
Overview
-
-
ManyToOne
Many instances of the current Entity refer to One instance of the referred Entity.
OneToMany
One instance of the current Entity has Many instances (references) to the referred Entity.
OneToOne
One instance of the current Entity refers to One instance of the referred Entity.
ManyToMany
Many instances of the current Entity refers to Many instances of the referred Entity.
-
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.
The identity map being indexed by primary keys only allows shortcuts when you ask for objects by primary key. When you query by other properties, you will still get the same reference, but two separate database calls will be made
-
-
-
-
Fundamentals
Collection.add()
& Collection.remove()
Collections have a matching method that allows to slice parts of data from a collection
-
Ref
wrapper to load entity automatically without explicit populate.
EntityRepository class carries the entity type, so we do not have to pass it to every find or findOne calls.
await orm.em.transactional(em => {
Or you can use begin/commit/rollback methods explicitly.
-
When cascade persisting collections, keep in mind only fully initialized collections will be cascade persisted.Note that cascade remove for collections can be inefficient as it will fire 1 query for each entity in collection.As opposed to the application level cascading controlled by the cascade option, we can also define database level referential integrity actions: on update and on delete.
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.
-
-
-
-
MikroORM uses identity map in background, so we will always get the same instance of one entity.RequestContext = that will use node's AsyncLocalStorage in the background to isolate the request context
1) RequestContext.create()
2) RequestContext.createAsync()
Advanced
SqlDrivers defaults to UnderscoreNamingStrategy, which means our all our database tables and columns will be lower-cased and words divided by underscored:
All drivers are currently supported (including sqlite and mongo). In postgres we also try to cast the value if we detect number or boolean on the right-hand side.
-
-