Cerial
A Prisma-like ORM for SurrealDB with schema-driven code generation and full TypeScript type safety.
$ npm install cerialSchema to queries in seconds
Define your schema, generate a client, and start querying with full type safety.
model User {
id Record @id
email Email @unique
name String
age Int?
role Role @default(Viewer)
createdAt Date @createdAt
posts Relation[] @model(Post)
}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.