Skip to content

omnidotdev/typespec-drizzle

TypeSpec Drizzle Emitter

A TypeSpec emitter that generates Drizzle ORM schema definitions and types from TypeSpec specifications. Learn about TypeSpec emitters here.

Important

Project Status: 🚧 This project is brand new. Use at your own risk.

Overview

This emitter allows you to define your database schema using TypeSpec's type-safe language and automatically generate Drizzle ORM schema files, enabling a single source of truth for your database schema definitions alongside other artifacts.

Features

  • Generate Drizzle schema definitions from TypeSpec models
  • Type-safe database schema generation
  • Support for common database types and constraints
  • Integration with TypeSpec's existing ecosystem

Installation

bun add -D @omnidotdev/typespec-drizzle

Usage

Basic Usage

  1. Add the emitter to your TypeSpec configuration (tspconfig.yaml):
emit:
  - "@omnidotdev/typespec-drizzle"
  1. Define your models in TypeSpec:
import "@omnidotdev/typespec-drizzle";

model User {
  id: string;
  email: string;
  name: string;
  createdAt: utcDateTime;
}

model Post {
  id: string;
  title: string;
  content: string;
  authorId: string;
  publishedAt?: utcDateTime;
}
  1. Run the TypeSpec compiler:
tsp compile .

The emitter will generate Drizzle schema files in the output directory.

Getting Started

Local Development

Use Tilt for a unified development experience:

tilt up

or manually install and build:

bun install
bun run build # or `bun run build:watch`

Tests can be run with bun test.

Contributing

See Omni's contributing docs.

License

The code in this repository is licensed under MIT, © Omni LLC. See LICENSE.md for more information.