PitchHut logo
drizzle-docs-generator
Efficiently convert Drizzle ORM schemas to DBML.
Pitch

Drizzle Docs Generator is a CLI tool that simplifies the process of generating DBML from Drizzle ORM schemas. By extracting JSDoc comments and converting them to DBML Notes, it enhances documentation and supports various features like directory imports and watch mode for automatic regeneration.

Description

The drizzle-docs-generator is a powerful CLI tool designed for developers working with Drizzle ORM. It enables seamless generation of DBML (Database Markup Language) from ORM schemas, making database documentation straightforward and efficient.

Key Features

  • Directory Import Support: Easily import all schema files from a specified directory to streamline the documentation process.
  • No File Extension Required: Supports extensionless imports, allowing for cleaner and more manageable imports (e.g., import { users } from './users').
  • JSDoc Comments Integration: Automatically extracts JSDoc comments and converts them into DBML Notes, enhancing schema clarity.
  • Relations Support: Generates references directly from relations() or defineRelations(), facilitating comprehensive relationship mapping within your database.
  • Watch Mode: Monitors schema files for changes and auto-regenerates documentation, ensuring your DBML documentation is always up-to-date.

Usage Examples

This tool is easy to use, with commands like:

# Basic usage for a single file
$ drizzle-docs generate ./src/db/schema.ts -d postgresql

# Importing all schema files from a directory
$ drizzle-docs generate ./src/db/schema/ -d postgresql

# Output DBML to a specific file
$ drizzle-docs generate ./src/db/schema.ts -d postgresql -o schema.dbml

# Generate using relations definitions
$ drizzle-docs generate ./src/db/schema.ts -d postgresql -r

# Enable watch mode for auto-regeneration on changes
$ drizzle-docs generate ./src/db/schema.ts -d postgresql -w

API Integration

The tool can also be integrated into applications using the following API:

import { pgGenerate } from "drizzle-docs-generator";
import * as schema from "./schema";

const dbml = pgGenerate({
  schema,
  source: "./schema.ts",
  relational: false,
  out: "./output.dbml", // optional
});

Requirements

  • Node.js version 24 or higher
  • Drizzle ORM version 1 beta (1.0.0-beta.10+)
  • Projects must support ES Modules (use "type": "module" in package.json).

This tool streamlines the process of generating database documentation, enhancing the development workflow and ensuring that schemas are clearly represented and easily maintainable.

0 comments

No comments yet.

Sign in to be the first to comment.