DEV Community

Cover image for Next-Generation ORM for Node.js
VORG
VORG

Posted on • Updated on

Next-Generation ORM for Node.js

prisma

Star 20.4k Watch 187 Fork 716

Image description

Prisma is a next-generation ORM that consists of these tools:

  • Prisma Client: Auto-generated and type-safe query builder for Node.js & TypeScript

  • Prisma Migrate: Declarative data modeling & migration system

  • Prisma Studio: GUI to view and edit data in your database

Prisma Client can be used in any Node.js or TypeScript backend application (including serverless applications and microservices). This can be a REST API, a GraphQL API a gRPC API, or anything else that needs a database.

Example

import { PrismaClient } from '@prisma/client'

const prisma = new PrismaClient()

// A main function so that you can use async/await
async function main() {
  const allUsers = await prisma.user.findMany({
    include: { posts: true },
  })
  // use console.dir to print nested objects
  console.dir(allUsers, { depth: null })
}

main()
.catch((e) => {
  throw e
})
.finally(async () => {
  await prisma.$disconnect()
})
Enter fullscreen mode Exit fullscreen mode

Top comments (0)