TypeORM is definitely the most mature Object Relational Mapper (ORM) available in the node.js world. Since it’s written in TypeScript, it works pretty well with the Nest framework.
The reference database for this article will be PostgreSQL.
npm install --save @nestjs/typeorm typeorm pg
To deploy our database we will use docker. To do it we simply need to run:
docker pull postgres
docker run --name [container_name] -e POSTGRES_PASSWORD=[database_password] -p 5432:5432 -d postgres
After that we just need to login and create a database:
docker exec -it postgresdb psql -U postgres
create database nestjs;
Now our database is ready to use.
Nest provides a level of abstraction above these common Node.js frameworks (Express/Fastify), but also exposes their APIs directly to the developer. …