This content originally appeared on DEV Community and was authored by Shashank Trivedi
1- Install Prisma: If you haven't installed Prisma yet, run the following commands to install it:
npm install prisma --save-dev
npx prisma init
2- Update the prisma/schema.prisma file:
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
3- Set the correct DATABASE_URL in your .env file, such as:
DATABASE_URL="postgresql://user:password@localhost:5432/mydb"
4- To generate prisma modal from existing tables
npx prisma db pull
/* This command will introspect the existing database and
automatically generate models in the `prisma/schema.prisma` file
based on the structure of your tables. */
5- Once the introspection is done, you can generate Prisma Client to interact with your database.
npx prisma generate
This content originally appeared on DEV Community and was authored by Shashank Trivedi
Shashank Trivedi | Sciencx (2024-10-21T11:10:30+00:00) Prisma ORM. Retrieved from https://www.scien.cx/2024/10/21/prisma-orm/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.