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.

Getting Started

npm install --save @nestjs/typeorm typeorm pg
Image for post
Image for post

Deploy Database

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.

Configuration Service


Image for post
Image for post

What is NestJS?

As mentioned at NestJS Documentation, Nest (NestJS) is a framework for building efficient, scalable Node.js server-side applications. It uses progressive JavaScript, is built with and fully supports TypeScript (yet still enables developers to code in pure JavaScript) and combines elements of OOP (Object Oriented Programming), FP (Functional Programming), and FRP (Functional Reactive Programming).

Under the hood, Nest makes use of robust HTTP Server frameworks like Express (the default) and optionally can be configured to use Fastify as well!

Nest provides a level of abstraction above these common Node.js frameworks (Express/Fastify), but also exposes their APIs directly to the developer. …

Rui Coelho

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store