API with NestJS #32. Introduction to Prisma with PostgreSQL. We learn the basics of Prisma and its main principles. We’ve been using TypeORM to manage our data and connect to our Postgres database. With Prisma, we describe our data using a Prisma schema file.
So far, in this series, we’ve been using TypeORM to manage our data and connect to our Postgres database. In this article, we look into Prisma, which is a capable alternative.
With Prisma, we describe our data using a Prisma schema file. It uses its own data modeling language and acts as a single source of truth. This differs from traditional ORMs that provide an object-oriented way of working with the database.
Every time we make changes to the schema file, we need to generate the Prisma client. In this process, Prisma parses our schema and creates a client along with all the TypeScript typings. This means that we no longer map SQL tables to model classes through the TypeScript code manually.
The Prisma client is a set of Node.js functions that we can call from within our code. Under the hood, the client connects to a query engine written in Rust.
Although it is possible to migrate from TypeORM to Prisma, in this aricle we set up our project from scratch.
You can find all of the code from this article in this repository.
Building Modern Nodejs Application using Nestjs and TypeScript - In this article, we will see how to build REST API using Nestjs with TypeScript. Building Modern Nodejs Application using Nestjs and TypeScript