From the course: Master Next.js by Building Scalable Apps with Routing, Databases, and Performance

Unlock this course with a free trial

Join today to access over 25,200 courses taught by industry experts.

Creating Prisma client

Creating Prisma client

So, now we are ready with the Prisma configuration. And in the end of last lecture, I mentioned that inside the package JSON, there was a dependency added, which was called at Prisma slash client. This dependency contains an object named Prisma client, which is extremely important and useful for connecting to the database and performing CRUD operations like add, edit, delete, etc. So, in this lecture, we are going to create the Prisma client and connect to the database. The first step to create Prisma client is to create a separate folder along with the file for the database. So, I will create a folder named db and inside it, I'll create the file index js. Inside this, we will create the db instance using the Prisma client. So, I'll say const Prisma client is equal to, we'll use the require and specify the package that is at Prisma slash client. Now let's create an instance, I'll say const db is equal to new Prisma client. We will use this db instance everywhere in the project. So, I…

Contents