Deprecated: Automatic conversion of false to array is deprecated in /home/u164338858/domains/areyoupop.com/public_html/wp-content/plugins/gs-facebook-comments/public/class-wpfc-public.php on line 258
Published On: January 30th, 2023Categories: AI News



Introduction

The most important thing when learning backend development is how to store the data. In this article, we look into how to create a database with PostgreSQL and connect it to NestJS. To manage a database easier, we’ll use an Object-relational mapping (ORM) tool called TypeORM.



Create the database

PostgreSQL, often simply “Postgres”, is an object-relational database management system. To quickly create a PostgreSQL database, we will use Docker ( make sure you installed Docker )

First, we create the docker-compose.yml file with these configurations

Image description

Then we create the docker.env file to store environment variables:

Image description

Okay, so now we have Docker and PostgreSQL, the next thing we want to do is to connect the database with NestJS



Connecting database

Before connecting NestJS app with the database, we need to install some dependencies:

  • @nestjs/typeorm typeorm : 2 libraries about TypeORM
  • pg : PostgreSQL…

Source link

Leave A Comment