Registry / database / prisma-zero

prisma-zero

JSON →
library0.1.3jsnpmunverified

Generate Zero schema files from Prisma ORM schemas. This generator (v0.1.3) is an early-stage tool that automatically creates table definitions, column mappings, and type-safe schemas compatible with Zero (the reactive sync engine from Rocicorp). It supports all standard Prisma data types, Postgres arrays (mapped to json<>), DateTime/Time types, enums, and optional fields. Ideal for developers migrating from Prisma to Zero or building apps that need both Prisma's schema management and Zero's real-time sync. Not yet stable; expect breaking changes in minor versions. Differentiates from @passionfroot/prisma-generator-zero by being officially maintained by Rocicorp.

npm install prisma-zero
INSTALL
IMPORT
SIG · PRISMA-ZERO
P
prisma-zero
databasejavascriptv0.1.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

table
import { table } from 'app/zero-schema'
import { table } from '@rocicorp/zero'
The generated schema file exports table, string, number, json, etc. Import from the generated file, not from @rocicorp/zero directly.
string
import { string } from 'app/zero-schema'
import { string } from '@rocicorp/zero'
Same as table; the types are re-exported from the generated schema for convenience.
userTable
import { userTable } from 'app/zero-schema'
const userTable = require('app/zero-schema').userTable
The generated schema exports named tables as const objects (e.g., userTable). Use ESM import syntax for proper tree-shaking and type inference.

Shows how to install the generator, configure it in Prisma schema, and use the generated schema with Zero's createSchema.

// 1. Install the generator // npm install prisma-zero // 2. Add generator to prisma/schema.prisma: // generator zero { // provider = "prisma-zero" // } // 3. Add build script to package.json: // "generate": "prisma generate" // 4. After running `npx prisma generate`, import the generated schema: import { table, string, number } from './generated/zero-schema'; // 5. Define Zero tables using the generated schema import { createSchema } from '@rocicorp/zero'; const schema = createSchema({ tables: [userTable, postTable], }); export type Schema = typeof schema;
Debug
Known issues
breakingGenerator output format or naming may change in minor versions before 1.0.0.
fix
Pin exact version and review changelog before upgrading.
affects: >=0.0.0 <1.0.0
deprecatedenableLegacyMutators and enableLegacyQueries options are deprecated in favor of using Zero's new mutator pattern.
fix
Remove these options and migrate to the new mutator API as described in Zero docs.
affects: >=0.1.0
gotchaDateTime fields with @db.Time or @db.Timetz are mapped to number() but require @rocicorp/zero v0.26.0+ for proper support.
fix
Update @rocicorp/zero to 0.26.0 or later.
affects: >=0.0.0
gotchaArray fields are mapped to json<> columns in Zero, which may affect query performance or indexing compared to native arrays.
fix
Consider whether json columns are acceptable for your use case; plan accordingly.
affects: >=0.0.0
Errors
Common errors & fixes
Error: Cannot find module '@rocicorp/zero'
@rocicorp/zero is a peer dependency that must be installed separately, and the generated schema expects it.
fix
Run `npm install @rocicorp/zero` and ensure it is in your package.json.
Unknown generator: prisma-zero
prisma-zero is not installed or Prisma cannot resolve it (e.g., missing npm install).
fix
Run `npm install prisma-zero` and regenerate with `npx prisma generate`.
TypeError: table is not a function
Possibly importing table from the wrong module (e.g., from @rocicorp/zero instead of the generated schema file).
fix
Import table from your generated schema file (e.g., `import { table } from '../generated/zero-schema'`).
Upgrade
Version history
0.1.3latest on npm
Audit
Dependencies
@rocicorp/zerorequiredThe generated schema depends on Zero's table(), string(), json(), etc. functions to create a valid Zero schema
prismarequiredThe generator runs as a Prisma generator and requires Prisma CLI for prisma generate
Agent activity
4 hits · last 30 days
node
4
Resources
prisma-zero — npm install prisma-zero · libregistry