A developer sets up a PostgreSQL database for a NestJS backend using the Prisma ORM. The process includes initializing the Prisma CLI, configuring connection strings in environment variables, using pgAdmin to manage the database, defining a user data model, and running migrations to sync the schema.
Length 9:42
Captions English (Generated), Spanish (Auto-translated), French (Auto-translated), Korean (Auto-translated), Portuguese (Auto-translated), Vietnamese (Auto-translated) #prisma #postgresql #nestjs #database #orm #typescript #migrations #pgadmin #backend #development
0:00 Okay, so we're ready to get started in setting 0:02 up our database 0:04 for our NestJS backend. We're gonna use Prisma in 0:08 this project, which is a very popular ORM tool, 0:12 an open source one for Node.js, and has first-class support for 0:15 TypeScript. 0:17 It also is gonna allow us to generate TypeScript code for the schema 0:21 definitions we specify, which is always gonna ensure that our database 0:25 schema is in line with our code, making it very easy to 0:28 write type-safe code. Type ORM supports many different types of 0:32 SQL servers. We're gonna go ahead and use PostgreSQL, which is the 0:36 default for Prisma. Let's go ahead and get 0:40 started by heading to our terminal, and firstly, we want to 0:43 install the Prisma CLI in our project. 0:47 So pnpm install @save dev prisma. 0:53 So now that we have Prisma CLI, let's go ahead and invoke it by 0:57 running pnpm prisma init to initialize Prisma 1:01 in our project. So let's head back to our project 1:04 and dive into 1:05 what the Prisma CLI has just done for us. 1:07 There are two things that it has done. 1:09 The first is that it's gone ahead and actually created this prisma 1:13 directory with a schema.prisma file. 1:16 We can go ahead and click on this. 1:18 Firstly, I wanna point out that I have syntax highlighting for this 1:22 file 1:22 because in VS Code I have the Prisma extension. 1:26 If you would like syntax highlighting, make sure you install this extension. 1:31 So this schema Prisma file is essentially the source of truth 1:35 for what our database should look like, and it's also going to provide the 1:39 connection details to our actual database. 1:42 Finally, this source of truth for our schema 1:44 is used by the Prisma 1:46 client to actually generate TypeScript types for us to use 1:50 in our NestJS backend. So that's what these first two blocks are
The rest of the transcript is for members.
Sign in