drizzle-orm

Generate type-safe SQL queries with schema definitions for PostgreSQL, MySQL, and SQLite.

8|Updated Mar 28, 2024
One-click install
npx skills add https://github.com/joncrangle/.dotfiles --skill drizzle-orm-joncrangle
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: drizzle-orm
Source: https://github.com/joncrangle/.dotfiles/tree/main/dot_config/opencode/skills/drizzle-orm
Command: npx skills add https://github.com/joncrangle/.dotfiles --skill drizzle-orm-joncrangle

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Type-safe SQL query construction and database access in TypeScript often requires boilerplate and unsafe string concatenation. Drizzle ORM provides a type-safe layer with defined schemas, migrations, and relations to simplify building robust data access.

Core Features & Use Cases

  • Type-safe schema definitions and relations with generated types.
  • Migrations and Drizzle Kit tooling to manage database schemas across environments.
  • Templates and examples for common databases (PostgreSQL, MySQL, SQLite) and server setup for Next.js or Node.js.

Quick Start

Install drizzle-orm and drizzle-kit, define your schema in src/db/schema.ts, and run drizzle-kit generate and migrate.

Frequently Asked Questions about drizzle-orm

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write type-safe SQL queries in TypeScript without unsafe string concatenation?

You write type-safe SQL queries by defining schemas and relations that enforce schema inference types, eliminating unsafe string concatenation for robust data access.

How do I generate and run database migrations in a Node.js app?

Database migrations are generated and run using Drizzle Kit tooling, executing `drizzle-kit generate` and `migrate` commands to manage database schemas across environments.

Does this ORM work with PostgreSQL, MySQL, and SQLite in Next.js projects?

Yes, this ORM supports PostgreSQL, MySQL, and SQLite, providing templates and examples for schema definitions and relational queries tailored for Next.js projects.

What is the best way to configure a TypeScript ORM for schema inference?

Configuring a TypeScript ORM for schema inference involves setting up a `drizzle.config.ts` file and defining your schema in `src/db/schema.ts` to automatically enforce inferred types.

How do I manage relational queries across multiple databases in TypeScript?

Relational queries across multiple databases are managed by defining relations within your schema, enabling type-safe relational data fetching across PostgreSQL, MySQL, and SQLite.