Generate Zero schemas from Drizzle ORM schemas.
npm install drizzle-zero
# or
yarn add drizzle-zero
# or
pnpm add drizzle-zero
Here's a simple example of how to convert a Drizzle schema to a Zero schema:
import { pgTable, text } from "drizzle-orm/pg-core";
import { createSchema, createTableSchema } from "@rocicorp/zero";
import { createZeroSchema } from "drizzle-zero";
// Define your Drizzle table
const userTable = pgTable("user", {
id: text("id").primaryKey(),
name: text("name").notNull(),
});
// Convert to Zero table schema and select columns
const userSchema = createTableSchema(
createZeroSchema(userTable, {
id: true,
name: true,
}),
);
// Create your Zero schema
export const schema = createSchema({
version: 1,
tables: {
user: userSchema,
},
});
- Convert Drizzle ORM schemas to Zero schemas
- Handles all Drizzle column types that are supported by Zero
- Type-safe schema generation
- Relationships are not supported yet
MIT