Storage

Prisma

@postel/prisma — run Postel's storage through your existing PrismaClient (Postgres, MySQL, or SQLite).

@postel/prisma is an ORM adapter: hand Postel your PrismaClient and it runs its storage through Prisma's raw query surface, sharing your connection and transactions.

pnpm add @postel/prisma
npm install @postel/prisma
yarn add @postel/prisma
bun add @postel/prisma

@prisma/client is a peer dependency — you already have it in a Prisma app.

lib/postel.ts
import { PrismaClient } from "@prisma/client";
import { Postel } from "@postel/core";
import { PrismaStorage } from "@postel/prisma";

const prisma = new PrismaClient();

export const postel = Postel({
  outbound: {
    storage: PrismaStorage({ prisma, dialect: "postgres" }),
  },
});

Options

OptionNotes
prismaYour PrismaClient instance.
dialect"postgres", "mysql", or "sqlite" — selects the reservation strategy (FOR UPDATE SKIP LOCKED on Postgres/MySQL, ordered on SQLite), the capability flags, and the column codecs.
autoMigrateRun migrations on first use (default true).
clockInject a clock for deterministic time in tests.

At runtime Postel calls Prisma only through its raw query surface ($queryRawUnsafe / $executeRawUnsafe / $transaction), so you add no Postel models to your schema.prisma — it works against any generated PrismaClient. @prisma/client is a peer dependency; the adapter imports only its type. The dialect names a SQL family, so wire-compatible engines (MariaDB, PlanetScale, libSQL/Turso, …) work via the matching dialect — see compatible databases.

Shared transactions

Use Prisma's interactive transaction and pass the transaction client to send():

await prisma.$transaction(async (tx) => {
  await tx.order.create({ data: { /* ... */ } });
  await postel.send({ type: "order.created", data: { /* ... */ } }, { tx });
});

Migrations

autoMigrate creates Postel's tables via raw SQL on first use (version-gated, idempotent) — independent of your Prisma schema. If you'd rather Prisma own those tables, model them from the canonical schema in your schema.prisma and run prisma migrate, then start the adapter with autoMigrate: false.

On this page