# kunii

> Workers-native ORM docs for Cloudflare D1 and Durable Object SQLite

Package: Kunii
Canonical: https://kuratchi.dev/docs/kunii
Markdown: https://kuratchi.dev/docs/kunii/index.md

## SQLite for the runtime you already have

`kunii` is a lightweight ORM for Cloudflare D1 and Durable Object SQLite. It keeps the API Worker-safe, uses a compact schema DSL, and stays close to SQL instead of hiding the database behind a large abstraction layer.

## What it gives you

- [Schema DSL](/docs/kunii/schema-dsl):
    Define tables, mixins, indexes, JSON columns, enums, and foreign keys with a compact object format.
- [Chainable queries](/docs/kunii/querying):
    Query with `where`, `orderBy`, `limit`, `offset`, `count`, and `distinct` without leaving SQL-shaped concepts behind.
- [Relations and JSON](/docs/kunii/relations):
    Load related rows, filter by relation existence, and query JSON columns with dotted paths.
- [Write helpers](/docs/kunii/writes-and-transactions):
    Use `returning`, `upsert`, and `db.batch()` for common write workflows and atomic commits.
- [D1 and DO support](/docs/kunii/getting-started):
    Use the same ORM across D1 bindings and Durable Object SQLite storage.
- [Framework adapters](/docs/kunii/framework-adapters):
    Initialize D1 migrations and clients in Cloudflare-hosted SvelteKit, Next, Nuxt, Astro, and Koze apps.
- [Migration helpers](/docs/kunii/migrations):
    Generate initial SQL, diff schemas, and run tracked runtime migrations when needed.

## Design constraints

The ORM is built around a few hard constraints:

- No Node-only runtime assumptions
- No dependency-heavy query layer
- SQL semantics stay visible
- Same mental model across D1 and Durable Object SQLite

## Read next

- [Getting Started](/docs/kunii/getting-started)
- [Schema DSL](/docs/kunii/schema-dsl)
- [Querying](/docs/kunii/querying)
- [Relations](/docs/kunii/relations)
- [JSON Columns](/docs/kunii/json-columns)
- [Writes and Transactions](/docs/kunii/writes-and-transactions)
- [Aggregates and Reporting](/docs/kunii/aggregates-and-reporting)
- [Type Generation](/docs/kunii/type-generation)
- [Framework Adapters](/docs/kunii/framework-adapters)
- [Migrations](/docs/kunii/migrations)
