Schema-first ORM for SurrealDB
Warning: Cerial is under active development and not yet ready for production use. APIs may change between releases.

Cerial

A Prisma-like ORM for SurrealDB with schema-driven code generation and full TypeScript type safety.

$ npm install cerial

Schema to queries in seconds

Define your schema, generate a client, and start querying with full type safety.

Schema
model User {
  id        Record    @id
  email     Email     @unique
  name      String
  age       Int?
  role      Role      @default(Viewer)
  createdAt Date      @createdAt
  posts     Relation[] @model(Post)
}
TypeScript
const users = await client.db.User.findMany({
  where: { isActive: true },
  select: { id: true, name: true, email: true },
  orderBy: { createdAt: 'desc' },
  limit: 10,
});

// Return type narrows automatically
// users: { id: CerialId; name: string; email: string }[]

Everything you need

A complete ORM with schema generation, type-safe queries, and rich tooling.

Schema-First

Define models in .cerial files with a clean, readable syntax. Generate a fully typed TypeScript client automatically.

Type-Safe Queries

findMany, findOne, create, update, delete with return types that narrow dynamically based on select and include.

Full Relations

1:1, 1:N, and N:N relations with nested create, connect, disconnect, and cascade behavior.

Transactions

Array mode, callback mode, and manual mode with retry support and automatic cleanup.

Rich Type System

CerialId, CerialUuid, CerialDuration, CerialDecimal, CerialBytes, CerialGeometry — wrapper classes with full APIs.

CLI & Tooling

Generate, format, watch mode, multi-schema support, and VS Code extension with IntelliSense.

Built for SurrealDB

Built specifically for SurrealDB — leveraging record links, multi-model capabilities, and SurrealQL natively.

63+
Test schemas
2600+
Unit tests
3.x
SurrealDB support
Apache 2.0
License

Ready to build?

Define your schema, generate your client, start querying.

Cerial — A Prisma-like ORM for SurrealDB

Apache 2.0 License · GitHub