SOPORTE 24/7
OFERTAS FLASH
70% DESCUENTO
DOMINIO GRATIS
HOSTING PREMIUM
SSL INCLUIDO
SOPORTE 24/7
OFERTAS FLASH
70% DESCUENTO
DOMINIO GRATIS
HOSTING PREMIUM
SSL INCLUIDO
Systems18 Ene, 2026Peter Lima28 min read

Database with Prisma

1,5409 lessons
Share:
Database with Prisma

Prisma is the most modern and popular ORM for Node.js and TypeScript. It greatly simplifies database management with a declarative schema, automatic migrations and a type-safe client.

Prerequisites

  • Node.js 18+ and npm installed
  • TypeScript knowledge
  • PostgreSQL, MySQL or SQLite available
  • A Node.js or Next.js project configured

Installation and schema

Prisma is installed as a dev dependency and generates a typed client based on your database schema. The schema is defined in a prisma/schema.prisma file.

prisma/schema.prisma
npm install prisma @prisma/client
npx prisma init

// prisma/schema.prisma
model User {
  id        Int      @id @default(autoincrement())
  email     String   @unique
  name      String?
  posts     Post[]
  createdAt DateTime @default(now())
}

model Post {
  id        Int      @id @default(autoincrement())
  title     String
  content   String?
  published Boolean  @default(false)
  author    User     @relation(fields: [authorId], references: [id])
  authorId  Int
}

Pro Tip

Use npx prisma studio to visually explore and edit your database data. It's an incredible tool for development and debugging.

Queries with Prisma Client

Prisma Client provides an intuitive and fully typed API for querying your database. TypeScript autocomplete makes queries safe and efficient.

Queries with Prisma
import { PrismaClient } from '@prisma/client'
const prisma = new PrismaClient()

// Create user
const user = await prisma.user.create({
  data: { email: 'peter@syxweb.com', name: 'Peter' }
})

// Get all published posts with author
const posts = await prisma.post.findMany({
  where: { published: true },
  include: { author: true },
  orderBy: { createdAt: 'desc' }
})

Conclusion

Prisma transforms the experience of working with databases in Node.js. Its declarative schema, automatic migrations and typed client eliminate a huge amount of errors and accelerate development.

THE AUTHOR

Peter Lima

Peter is a full stack web developer with over 5 years of experience creating digital solutions. Specialist in React, Next.js and Node.js, passionate about sharing knowledge and helping other developers grow professionally.

More from Peter Lima

Comments

Nicolas Soto

January 14, 2026

Prisma is incredible! This tutorial helped me migrate from Mongoose to Prisma in my project.

Valentina Parra

January 11, 2026

Very well explained schema. The relationships between models were super clear.

Emilio Rios

January 8, 2026

Excellent tutorial. Prisma Studio is a tool I didn't know about and now I can't live without it.