Object Relational Mappers (also known as ORMs) are a fundamental component of modern application design. An ORM is basically a layer of between the application and data.
TypeORM is a very popular ORM in Javascript and Typescript world. It supports two important patterns - Active Record and Data Mapper. While both patterns solve the problem of connecting applications with data, they both follow different philosophies. Basically, both patterns have their own advantages and disadvantages.
In the Active Record pattern, we define all the query methods for accessing the data within the model class itself. In other words, all operations such as create, read, update and delete are performed directly using the model methods.
To implement Active Record pattern in TypeORM, we need to use the BaseEntity class. This class is provided by the typeorm package.
The Data Mapper pattern is also known as the Repository pattern. In this pattern, the query methods are kept in a separate class known as repositories.
Basically, in the Data Mapper pattern, entities have no logic. The logic of dealing with the data is within the repository classes.
In this video, we look at examples for both Active Record and Data Mapper with TypeORM. There is also a companion blog post that can be found at the below link:
https://progressivecoder.com/typeorm-...
00:00 - Introduction
01:37 - Active Record Pattern in TypeORM
03:03 - Active Record Advantages and Disadvantages
04:26 - Data Mapper Pattern in TypeORM
05:31 - Data Mapper Advantages and Disadvantages
#TypeORM #Javascript #Typescript
++++++++++++++++++++++++++++++++++++++++++++++++
Visit my General Tech Blog for lots of how-to articles on various technologies:
http://www.progressivecoder.com
Visit my Web Development Specific Tech Blog if you are interested only about web development:
https://www.progressivewebninja.com
You can also check out my Github account for examples I have built:
https://www.github.com/dashsaurabh
+++++++++++++++++++++++++++++++++++++++++++++++++