<aside> 💡

ORM helps us to easily interact with the database without, thinking about the syntax Example:- SQL

</aside>

Why ORM’s

  1. Simple Syntax
  2. You can switch between different databases (e.g., PostgreSQL, MySQL, SQLite) without rewriting all your queries.
  3. Allows Type Safety
  4. Automatic Migrations

<aside> 💡

Prisma Is one of the ORM which does these all

</aside>


Install Prisma

  1. Initialize Node JS Project

    npm init -y
    
  2. Install Prisma dependencies

    npm install prisma
    
  3. Initialize Prisma

    npx prisma init
    
  4. Install Prisma VS Code Extension → https://marketplace.visualstudio.com/items?itemName=Prisma.prisma


Models in Prisma

model User {
  id Int @id @default(autoincrement())
  email String @unique
  firstName String
  lastName String?
  username String @unique
  password String
}

model todos {
  id Int @id @default(autoincrement())
  title String
  description String?
  done Boolean @default(false)
  userId Int
}

Generate Migrtions