TypeScript ORM with zero-cost type-safety for your database
Query data from MySQL, PostgreSQL & SQL Server databases with Prisma – a type-safe TypeScript ORM for Node.js
Why Prisma and TypeScript?
Type-safe database client
Prisma Client ensures fully type-safe database queries so that you never write an invalid query
Optimized database queries
Prisma's built-in dataloader ensures optimized and performant database queries, even for N+1 queries.
Autocompletion
Prisma helps you write your queries with rich autocompletion as you write queries
Type inference
Queries with Prisma Client always have their return type inferred making it easy to reason about your data.
Easy database migrations
Map your Prisma schema to the database so you don't need to write SQL to manage your database schema.
Filters, pagination & ordering
Prisma Client reduces boilerplates by providing convenient APIs for common database features.
How Prisma and TypeScript fit together
Zero-cost type-safety
Queries with Prisma Client always have their return type inferred making it easy to reason about the returned data – even when you fetch relations.
// Inferred type:
// User & {
// posts: Post[];
// }
const user = await prisma.user.create({
data: {
email: 'alice@prisma.io',
password: '0ee4808f893b8e05bdd251048d5c4c8af8bb89403676dda95619841a481f8e87',
name: 'Alice',
posts: {
create: {
title: 'Learn how to use Prisma with TypeScript',
content: 'https://www.prisma.io/docs/',
},
},
},
include: {
posts: true,
},
})Generated TypeScript Types for your database tables
Prisma keeps your TypeScript types in sync with the database schema. Below are the types generated by Prisma from the Prisma schema.
type User = {
id: string
email: string
password: string
name: string | null
}
export type Post = {
id: string
createdAt: Date
title: string
content: string | null
authorId: string
}Our TypeScript Resources
TypeScript Berlin Meetup
The TypeScript Berlin Meetup started in 2019 and is one of the most popular TypeScript Meetups in the world.
Prisma TypeScript examples
Ready-to-run example projects using Prisma, TypeScript and a variety of different frameworks and API technologies