Distributed data,
Powerful tooling with
Prisma & CockroachDB

Manage your data at scale with CockroachDB and Prisma – a next-generation ORM for Node.js and TypeScript.

What is Prisma?

Prisma is an open-source ORM that drastically simplifies data modeling, migrations, and data access for SQL databases in Node.js and TypeScript.

Query
// Creating a new record
await prisma.user.create({
firstName: “Alice”,
email: “alice@prisma.io”
})
Table
id firstName email
1 Bobby bobby@tables.io
2 Nilufar nilu@email.com
3 Jürgen jums@dums.edu
4 Alice alice@prisma.io

How Prisma and CockroachDB fit together

CockroachDB is a relational, PostgreSQL wire-protocol-compatible database built for cloud applications and services. It automates the task of scale, so developers no longer have to choose between the data integrity offered by a relational database or the availability of NoSQL. And, when using CockroachDB developers don’t have to worry about deployment or ongoing administration/management of the database.

Prisma is an open-source ORM that integrates seamlessly with CockroachDB and supports the full development cycle. Prisma helps you define your database schema declaratively using the Prisma schema and fetch data from CockroachDB with full type safety using Prisma Client.

Together the two technologies give developers access to the scalable infrastructure of a distributed database without requiring them to be experts in hosting and scaling databases.

The Prisma schema

The Prisma schema uses Prisma's modeling language to define your database schema. It makes data modeling easy and intuitive, especially when it comes to modeling relations.

Migrating your database schema is painless: you update the data model in your Prisma schema, run prisma db push to apply the schema changes, and CockroachDB will handle applying those changes to each database in your cluster.

// Define the `User` table in the database
model User {
id String @id @default(cuid())
email String @unique
password String
name String?
posts Post[]
}
// Define the `Post` table in the database
model Post {
id String @id @default(cuid())
title String
content String?
authorId String
author User @relation(fields: [authorId], references: [id])
}

“CockroachDB and Prisma is a match made in heaven. Not only does it simplify data but it also eliminates database operations so you can focus on what you want to…your code.”

Aydrian HowardAydrian Howard -
Developer Advocate of Cockroach Labs

Why Prisma and CockroachDB?

Zero downtime migrations

CockroachDB clusters your databases into a single logical database, allowing it to apply schema migrations incrementally.

Introspection & optimization tools

Introspection allows you to pull down and easy-to-read representation of your database's schema. Here you have the ability to view and modify your indexes.

Deploy to multiple cloud providers

CockroachDB multi-cloud deployments allow you to avoid cloud-specific outages by deploying your database cluster to multiple providers at once.

Type-safe database client

Prisma Client ensures fully type-safe database queries with benefits like autocompletion - even in JavaScript.

Referential integrity with serverless

CockroachDB's distributed data model allows you to manage your relational data as if it were in a single logical database.

Intuitive data modeling

Prisma's modeling language is declarative and lets you intuitively describe your database schema.

blog post

Prisma Support for CockroachDB Is Production Ready

In this article, we announce the general availability of the Prisma CockroachDB connector and take a look at some of the reasons why you should use Prisma and CockroachDB together.

showcase

How Tryg has leveraged Prisma to democratize data

How Tryg transforms billions of records from different data sources, and expose a single data model via GraphQL and Prisma.

Our Prisma & CockroachDB Resources

CockroachDB Data Source Connector Documentation

This section of the docs covers the details of Prisma's CockroachDB data source connector.

Using Prisma with CockroachDB

In this section of the docs, you will learn about the concepts behind using Prisma and CockroachDB, the commonalities and differences between CockroachDB and other database providers, and the process for configuring your application to integrate with CockroachDB.

Get Involved

Join the CockroachDB + Prisma Community

Join us on Slack

Get help and engage with thousands of CockroachDB and Prisma developers on Slack

Join Prisma Slack

Showcase on Twitter

We’d love to see what you’re building with CockroachDB and Prisma

Tweet #prisma+cockroachdb

Get Stickers

Show your CockroachDB + Prisma love with custom free stickers

Order stickers
prisma_logo

© 2022 Prisma Data, Inc.

Newsletter

Stay up to date with the latest features and changes to Prisma