Drizzle ORM

website·Indexed 32 days ago

https://drizzle.zhcndoc.com

A lightweight, modern TypeScript ORM designed to be a type-safe layer over SQL. It features a codebase-first workflow, a powerful migration tool called drizzle-kit, and specialized support for databases like CockroachDB. The ecosystem includes drizzle-seed for generating deterministic fake data and effect-schema for generating effect schemas from Drizzle ORM schemas.

Tokens
343.1K
Snippets
2.2K
Records
2.3K
Agent score
47%

What's inside Drizzle

  1. Overview of Drizzle Migration Strategies

    Drizzle supports two primary philosophies for managing database schemas:

    1. Database-First: The database schema is the source of truth. You manage the schema directly in the database or via external tools, and then pull that schema into your TypeScript code.
    2. Code-First: The TypeScript schema definition is the source of truth and is version-controlled. You define the schema in code and apply it to the database using Drizzle tools.
  2. Overview of Drizzle ORM

    Drizzle ORM is a lightweight, type-safe TypeScript ORM designed for high performance and serverless deployments. It features zero dependencies and supports multiple database dialects including PostgreSQL, MySQL, SQLite, SingleStore, MSSQL, and CockroachDB. Unlike traditional 'data frameworks', Drizzle is designed to be non-intrusive, allowing developers to build projects without being forced into a specific structural pattern.
  3. Overview of Drizzle ORM

    Drizzle ORM is a lightweight, high-performance, and type-safe TypeScript ORM designed for serverless environments. It is unique in providing both a SQL-like query API and a relational query API. It has zero dependencies and supports multiple database dialects including PostgreSQL, MySQL, SQLite, SingleStore, MSSQL, and CockroachDB.
  4. Overview of Drizzle ORM Query APIs

    Drizzle ORM provides two distinct ways to access data:

    1. SQL-like API: A type-safe wrapper around SQL that mirrors SQL syntax, ideal for those who know SQL and want full control.
    2. Relational Queries API (RQB): A higher-level API for easily fetching nested relational data without manual joins, while still outputting a single optimized SQL query.
    // SQL-like API example
    await db
      .select()
      .from(countries)
      .leftJoin(cities, eq(cities.countryId, countries.id))
      .where(eq(countries.id, 10));
    
    // Relational Queries API example
    const result = await db.query.users.findMany({
      with: {
        posts: true
      },
    });
  5. Overview of Drizzle Migration Workflows

    Drizzle supports two primary workflows for managing database schemas:

    1. Database First: The database schema is the source of truth. You manage the schema directly in the database or via external tools, then pull that schema into your codebase as TypeScript entities.
    2. Codebase First: The TypeScript schema in your code is the source of truth and is version-controlled. You define the schema in JS/TS and apply it to the database using Drizzle tools.
  6. Overview of drizzle-seed

    drizzle-seed is a TypeScript library used to populate databases with deterministic, realistic fake data. It uses a seedable pseudorandom number generator (pRNG), ensuring that the same seed value always produces the same data set, which is critical for consistent testing, debugging, and collaboration across development environments.
  7. Overview of drizzle-seed for deterministic data generation

    drizzle-seed is a TypeScript library used to populate databases with realistic fake data. It uses a pseudo-random number generator (pRNG) to ensure that data generation is deterministic; using the same seed value will always produce the same dataset, which is critical for consistent testing, debugging, and team collaboration.
  8. Overview of Drizzle migration workflows

    Drizzle supports two primary workflows for managing database schemas:

    1. Database-First: The database schema is the source of truth. You manage the schema directly in the database or via external tools and use Drizzle to pull that schema into TypeScript files.
    2. Code-First: The TypeScript schema is the source of truth and is version-controlled. You define the schema in code and apply it to the database using Drizzle tools.
  9. Overview of Drizzle ORM

    Drizzle ORM is a lightweight, type-safe TypeScript ORM designed to be "headless," meaning it doesn't force a specific project structure on the developer. It is specifically optimized for serverless environments, featuring zero dependencies and high performance. It supports multiple database dialects including PostgreSQL, MySQL, SQLite, SingleStore, MSSQL, and CockroachDB.
  10. Overview of Drizzle ORM

    Drizzle ORM is a lightweight, headless TypeScript ORM designed for serverless environments. It features zero dependencies and provides two ways to interact with data: a SQL-like API for those who prefer standard SQL syntax and a Relational Query API (Rקב) for efficient extraction of nested relational data without manual joins. It supports PostgreSQL, MySQL, and SQLite via industry-standard drivers.
  11. Overview of Drizzle migration workflows

    Drizzle supports two primary workflows for managing database schemas:

    1. Database First: The database schema is the single source of truth. You manage the schema directly in the database or via external tools and pull the state into your TypeScript code.
    2. Codebase First: The TypeScript schema definition is the single source of truth and is version-controlled. You define the schema in code and apply it to the database using Drizzle tools.
  12. Introduction to Drizzle ORM

    Drizzle is a lightweight (~7.4kb minified+gzipped), tree-shakeable TypeScript ORM with zero dependencies. It is designed to be serverless-ready and provides support for PostgreSQL, MySQL, SQLite, and SingleStore databases.