# VibORM

> Type-safe ORM for PostgreSQL, MySQL, and SQLite with a Prisma-inspired API.

## Docs

- [Introduction](https://viborm.dev/docs): Prisma-inspired TypeScript ORM without code generation or WASM query-engine deployment issues
- [Why We Built This](https://viborm.dev/docs/why): The story behind VibORM — vibe coding, Prisma friction, and building from first principles
- [CLI](https://viborm.dev/docs/cli): Validate schemas, preview changes, and manage migrations
- [Studio](https://viborm.dev/docs/studio): Browse your schema as a diagram, and your rows through your own client

## Getting Started

- [Installation](https://viborm.dev/docs/getting-started): Get started with VibORM in your project
- [Quick Start](https://viborm.dev/docs/getting-started/quick-start): Build your first VibORM schema in 5 minutes with a simple blog example featuring users and posts
- [Configuration](https://viborm.dev/docs/getting-started/configuration): Configure VibORM with viborm.config.ts for CLI commands like push and migrate
- [Package entry points](https://viborm.dev/docs/getting-started/package-entry-points): The complete supported import map for VibORM V1
- [Upgrading to V1](https://viborm.dev/docs/getting-started/upgrading-to-v1): Move from VibORM 0.1.0 or a development checkout to the V1 public API and storage contracts

## Drivers

- [Database Drivers](https://viborm.dev/docs/drivers): Overview of available database drivers for VibORM
- [Namespaces](https://viborm.dev/docs/drivers/namespaces): Target one PostgreSQL schema or one MySQL database per driver
- [SurrealDB](https://viborm.dev/docs/drivers/surrealdb): Use VibORM with SurrealDB, through its own query language
- [Snowflake](https://viborm.dev/docs/drivers/snowflake): Read a Snowflake warehouse with VibORM, over the SQL API
- [Production connections](https://viborm.dev/docs/drivers/production): Pool ownership, readiness, transaction deadlines and driver recovery

### PostgreSQL

- [pg (node-postgres)](https://viborm.dev/docs/drivers/postgresql/pg): PostgreSQL driver using node-postgres with connection pooling
- [postgres.js](https://viborm.dev/docs/drivers/postgresql/postgres): Modern PostgreSQL driver using postgres.js
- [PGlite](https://viborm.dev/docs/drivers/postgresql/pglite): Embedded PostgreSQL using WebAssembly
- [Neon HTTP](https://viborm.dev/docs/drivers/postgresql/neon-http): Serverless PostgreSQL driver for Neon
- [Bun SQL](https://viborm.dev/docs/drivers/postgresql/bun-sql): PostgreSQL driver using Bun's built-in SQL client

### MySQL

- [MySQL2](https://viborm.dev/docs/drivers/mysql/mysql2): MySQL driver using mysql2 with connection pooling
- [PlanetScale](https://viborm.dev/docs/drivers/mysql/planetscale): Serverless MySQL driver for PlanetScale

### SQLite

- [better-sqlite3](https://viborm.dev/docs/drivers/sqlite/sqlite3): SQLite driver using better-sqlite3
- [LibSQL (Turso)](https://viborm.dev/docs/drivers/sqlite/libsql): SQLite driver for Turso and libSQL
- [Bun SQLite](https://viborm.dev/docs/drivers/sqlite/bun-sqlite): SQLite driver using Bun's built-in SQLite
- [Cloudflare D1](https://viborm.dev/docs/drivers/sqlite/d1): SQLite driver for Cloudflare D1 using Worker bindings
- [Durable Objects](https://viborm.dev/docs/drivers/sqlite/durable-object): SQLite driver for a Cloudflare Durable Object's own storage (ctx.storage.sql)

## Schema

- [Schema Definition](https://viborm.dev/docs/schema): Define type-safe database schemas with a fluent, chainable API for models, scalars, and relations
- [Model](https://viborm.dev/docs/schema/model): Define database tables with fields: scalar columns and relation associations
- [JSON schemas](https://viborm.dev/docs/schema/json): Define a schema as a JSON document — the surface for programmatic and agent-written schemas
- [From an existing database](https://viborm.dev/docs/schema/introspect): Read a PostgreSQL, MySQL, SQLite or Snowflake database into a JSON schema document, and query it at once
- [Native Types](https://viborm.dev/docs/schema/native-types): Override most scalar column types with database-specific native types
- [Schema Validation](https://viborm.dev/docs/schema/validation): When relation and schema rules run during client construction, push, migrate, and explicit validation

### Scalars

- [Scalars Overview](https://viborm.dev/docs/schema/scalars): Scalar types for database columns with chainable modifiers
- [String](https://viborm.dev/docs/schema/scalars/string): String scalar type for text data with auto-generation, validation, and native type options
- [Number](https://viborm.dev/docs/schema/scalars/number): Integer, approximate-number, and decimal scalar types with different precision characteristics
- [Boolean](https://viborm.dev/docs/schema/scalars/boolean): Boolean scalar type for true/false values with common patterns like soft delete and feature flags
- [DateTime](https://viborm.dev/docs/schema/scalars/datetime): DateTime, date, and time scalar types for timestamps with auto-timestamp helpers
- [Decimal](https://viborm.dev/docs/schema/scalars/decimal): Exact fixed-decimal values with one portable precision and scale
- [BigInt](https://viborm.dev/docs/schema/scalars/bigint): BigInt scalar type for large integers beyond JavaScript's Number.MAX_SAFE_INTEGER
- [JSON](https://viborm.dev/docs/schema/scalars/json): JSON scalar type for structured data — untyped or typed with a StandardSchema validator
- [Blob](https://viborm.dev/docs/schema/scalars/blob): Blob scalar type for binary data like files, images, or encrypted content
- [Enum](https://viborm.dev/docs/schema/scalars/enum): Enum scalar type that restricts values to a predefined set of options
- [GeoPoint](https://viborm.dev/docs/schema/scalars/point): Portable longitude/latitude storage, area filters, and distance queries
- [Vector](https://viborm.dev/docs/schema/scalars/vector): Vector scalar type for AI/ML embeddings and similarity search (PostgreSQL pgvector)

### Relations

- [Relations Overview](https://viborm.dev/docs/schema/relations): Define ordinary and polymorphic relationships between models
- [One-to-One](https://viborm.dev/docs/schema/relations/one-to-one): Define relations in which each side can reference at most one record
- [One-to-Many](https://viborm.dev/docs/schema/relations/one-to-many): Define one-to-many relationships connecting a single record to multiple related records
- [Many-to-One](https://viborm.dev/docs/schema/relations/many-to-one): Define many-to-one relationships connecting multiple records to a single related record
- [Many-to-Many](https://viborm.dev/docs/schema/relations/many-to-many): Define many-to-many relationships connecting multiple records on both sides
- [Polymorphic Relations](https://viborm.dev/docs/schema/relations/polymorphic): Relate one record to one of several independent target models with a type-safe discriminator

## Client

- [Client API](https://viborm.dev/docs/client): Query and mutate data with full type safety — all operations inferred from your schema, no code generation required
- [Types and JSON Schema](https://viborm.dev/docs/client/types-and-json-schema): Derive application types, validate operation inputs, and export JSON Schema from your models
- [Nested Writes](https://viborm.dev/docs/client/nested-writes): Create, update, and manage related records in a single operation
- [Selecting Fields](https://viborm.dev/docs/client/selecting): Control which fields are returned from queries using select and include
- [Omitting Fields](https://viborm.dev/docs/client/omit): Control model row projections, client defaults, and per-query projections
- [Sorting](https://viborm.dev/docs/client/sorting): Order query results using orderBy
- [Pagination](https://viborm.dev/docs/client/pagination): Paginate query results using offset-based or cursor-based pagination
- [Performance opt-ins](https://viborm.dev/docs/client/opt-ins): Facts about your data that make some reads much faster, what each changes in the SQL, and when not to state them
- [Transactions & Batching](https://viborm.dev/docs/client/transactions): Execute multiple operations with callback transactions or atomic batch mode
- [Raw SQL](https://viborm.dev/docs/client/raw-sql): Tagged-template $queryRaw/$executeRaw, the Unsafe variants, and the sql composition helpers
- [Errors](https://viborm.dev/docs/client/errors): Typed error classes, the V#### code taxonomy, and compiler-checked narrowing on error.code
- [Compatibility](https://viborm.dev/docs/client/compatibility): What's supported, and how VibORM intentionally differs from Prisma

### Create

- [create](https://viborm.dev/docs/client/create): Create new records in your database
- [createMany](https://viborm.dev/docs/client/create-many): Create multiple records in a single operation

### Read

- [findMany](https://viborm.dev/docs/client/find-many): Find multiple records matching your criteria with filtering and pagination
- [findFirst](https://viborm.dev/docs/client/find-first): Find the first record matching a filter, or null
- [findUnique](https://viborm.dev/docs/client/find-unique): Find a single record by unique identifier (primary key or unique scalar)
- [exist](https://viborm.dev/docs/client/exist): Check whether any record matches a filter, returning a boolean
- [count](https://viborm.dev/docs/client/count): Count records matching a filter
- [aggregate](https://viborm.dev/docs/client/aggregate): Compute count, sum, average, min, and max across records
- [groupBy](https://viborm.dev/docs/client/group-by): Group records and compute aggregates per group

### Update

- [update](https://viborm.dev/docs/client/update): Update existing records in your database
- [updateMany](https://viborm.dev/docs/client/update-many): Update every record matching a filter
- [upsert](https://viborm.dev/docs/client/upsert): Create a record if it doesn't exist, or update it if it does

### Delete

- [delete](https://viborm.dev/docs/client/delete): Remove records from your database
- [deleteMany](https://viborm.dev/docs/client/delete-many): Delete every record matching a filter

### Filtering

- [Filtering](https://viborm.dev/docs/client/filtering): Filter operators for the where clause, varying by scalar type
- [String Filters](https://viborm.dev/docs/client/filtering/string): Filter operators for string scalars
- [Number Filters](https://viborm.dev/docs/client/filtering/number): Filter operators for integer, approximate-number, fixed-decimal, and bigint scalars
- [Boolean Filters](https://viborm.dev/docs/client/filtering/boolean): Filter operators for boolean scalars
- [DateTime Filters](https://viborm.dev/docs/client/filtering/datetime): Filter operators for datetime scalars
- [JSON Filters](https://viborm.dev/docs/client/filtering/json): Filter operators for JSON scalars
- [Array Filters](https://viborm.dev/docs/client/filtering/arrays): Filter operators for array scalars
- [Field references and SQL fragments](https://viborm.dev/docs/client/filtering/field-references): Compare a column against another column of the same row, or against an SQL expression you write yourself
- [Relation Filters](https://viborm.dev/docs/client/filtering/relations): Filter records by their related models
- [To-One Relation Filters](https://viborm.dev/docs/client/filtering/relations-to-one): Filter by singular relation slots using is and isNot
- [To-Many Relation Filters](https://viborm.dev/docs/client/filtering/relations-to-many): Filter by collection relation slots using some, every, and none

## Migrations

- [Migrations](https://viborm.dev/docs/migration): Manage database schema changes with VibORM migrations
- [Push](https://viborm.dev/docs/migration/push): Synchronize models directly with the live database without creating migration history
- [Migrate](https://viborm.dev/docs/migration/migrate): Authenticated state-graph migrations — review exact SQL, publish immutable estate states, and apply them with a marker and ledger
- [Converting identifier columns](https://viborm.dev/docs/migration/identifiers): Moving an existing text column onto compact identifier storage, per dialect, with the pre-checks that make it safe
- [Compared with Prisma and Drizzle](https://viborm.dev/docs/migration/comparison): How VibORM V1 differs in migration history, artifact integrity, recovery, push, and programmatic use
- [Tenant Migrator](https://viborm.dev/docs/migration/tenant-migrator): Change one tenant's schema from its Durable Object, with every outcome returned
- [Per-Tenant Schemas from Durable Objects](https://viborm.dev/docs/migration/per-tenant-schemas-durable-objects): Give each tenant its own database and schema, and change that schema at runtime from the tenant's Durable Object

### Storage

- [Storage](https://viborm.dev/docs/migration/storage): Semantic estate storage for snapshots, SQL blobs, and state manifests
- [Filesystem Storage](https://viborm.dev/docs/migration/storage/filesystem): Store a Migration V1 estate on the local filesystem
- [Durable Object Storage](https://viborm.dev/docs/migration/storage/durable-object): Keep a tenant's migration history in its Durable Object's own storage
- [R2 Storage](https://viborm.dev/docs/migration/storage/r2): Keep migration histories in an R2 bucket

### Migration Drivers

- [Migration Drivers](https://viborm.dev/docs/migration/drivers): Database-specific DDL generation, schema introspection, and type mapping
- [PostgreSQL Driver](https://viborm.dev/docs/migration/drivers/postgresql): PostgreSQL migration types, enum transitions, and transaction guarantees
- [MySQL Driver](https://viborm.dev/docs/migration/drivers/mysql): MySQL migration support with inline ENUM columns, btree/fulltext/spatial indexes, and InnoDB-aware type handling
- [SQLite Driver](https://viborm.dev/docs/migration/drivers/sqlite): SQLite migration storage, table reconstruction, and provider limits
- [SurrealDB Driver](https://viborm.dev/docs/migration/drivers/surrealdb): SurrealQL schema, records and references, indexes, and what SurrealDB migrations do differently

## Extensions

- [Extensions](https://viborm.dev/docs/extensions): Extend a client with calls, units, arguments, rules, defaults, methods and computed fields, each part paying only for itself
- [Create an extension](https://viborm.dev/docs/extensions/create): Build a typed extension from the narrowest parts that do the job
- [Recipes](https://viborm.dev/docs/extensions/recipes): Tenancy, audit stamping and optimistic locking, each one extension you copy into your code
- [Migrating an extension](https://viborm.dev/docs/extensions/migrating): Move an extension written for the earlier contract to parts, member by member
- [Default omit](https://viborm.dev/docs/extensions/omit): Add typed default field omission to one derived client
- [Soft delete](https://viborm.dev/docs/extensions/soft-delete): Keep deleted rows as tombstones, hide them from reads, restore or purge them
- [Permissions](https://viborm.dev/docs/extensions/permissions): Who may read and write which rows, written as one where per model and action and checked by the database inside each statement
- [Write hooks](https://viborm.dev/docs/extensions/on): Run your code after a write commits, with the rows it wrote
- [Ordering](https://viborm.dev/docs/extensions/ordering): Keep the members of a list in the order you choose, and move one by writing one row

### Cache

- [Caching](https://viborm.dev/docs/extensions/cache): Official query-cache extension with invalidation and stale-while-revalidate

#### Drivers

- [Cache Drivers](https://viborm.dev/docs/extensions/cache/drivers): Multiple cache backends with a unified driver interface
- [MemoryCache](https://viborm.dev/docs/extensions/cache/drivers/memory): In-memory cache driver using JavaScript Map for development and single-instance deployments
- [CloudflareKVCache](https://viborm.dev/docs/extensions/cache/drivers/cloudflare-kv): Distributed cache driver using Cloudflare Workers KV for persistent, globally distributed caching
- [Custom Drivers](https://viborm.dev/docs/extensions/cache/drivers/custom): Implement your own cache driver for any backend by extending CacheDriver

### Instrumentation

- [Instrumentation](https://viborm.dev/docs/extensions/instrumentation): Official tracing, logging, and diagnostic disclosure
- [Logging](https://viborm.dev/docs/extensions/instrumentation/logging): Structured query, cache, and error logs
- [Tracing](https://viborm.dev/docs/extensions/instrumentation/tracing): OpenTelemetry spans from VibORM's lifecycle units

## Internals

- [Internals Overview](https://viborm.dev/docs/internals): The 12-layer architecture transforming type-safe schema definitions into database queries without code generation
- [Architecture](https://viborm.dev/docs/internals/architecture): Design principles, data flow, and critical architectural rules for VibORM's layered system
- [L2 - Scalars](https://viborm.dev/docs/internals/scalars): Scalar type definitions with State generic for compile-time tracking
- [L3 - Operation Schemas](https://viborm.dev/docs/internals/query-schemas): Validation schemas generated for where, create, update, and args operations
- [L4 - Relations](https://viborm.dev/docs/internals/relations): How ordinary and polymorphic relations declare cardinality, storage, and inverse topology
- [L5 - Schema Validation](https://viborm.dev/docs/internals/schema-validation): Reject structurally invalid model definitions before database work begins
- [L6 - Query Engine](https://viborm.dev/docs/internals/query-engine): Admit operations, compile portable queries, and execute provider statements
- [Performance](https://viborm.dev/docs/internals/performance): What each query type sends to each database, and the optimizations behind it
- [L7 - Adapters](https://viborm.dev/docs/internals/adapters): Translate VibORM's database-agnostic operations into dialect-specific SQL
- [L8 - Drivers](https://viborm.dev/docs/internals/drivers): Handle database connections and execute queries
- [L9 - Client](https://viborm.dev/docs/internals/client): The orm.model.operation() interface providing type-safe queries with zero code generation
- [L10 - Cache](https://viborm.dev/docs/internals/cache): Cache read results without moving query execution or persistence into the cache layer
- [L11 - Instrumentation](https://viborm.dev/docs/internals/instrumentation): Observe VibORM operations without changing their query semantics
- [L12 - Migrations](https://viborm.dev/docs/internals/migrations): Authenticated estate graph and history-free push — one differ, one compiler, dialect SQL in the bound migration driver

### L1: Validation

- [Overview](https://viborm.dev/docs/internals/validation): Standard Schema V1-compliant validation primitives (v.*) serving as VibORM's type system foundation
- [Standard Schema V1](https://viborm.dev/docs/internals/validation/standard-schema): Standard Schema V1 compliance for interoperability with the validation ecosystem

## Agent resources

- [llms-full.txt](https://viborm.dev/llms-full.txt): The full Markdown of every page in one file.
- [Page Markdown](https://viborm.dev/index.md): Append `.md` to any page URL to fetch that page as raw Markdown.
- [JSON API](https://viborm.dev/api/docs/pages.json): Page index of the JSON docs API; each entry links the page's JSON and Markdown forms. Described by the OpenAPI document at https://viborm.dev/openapi.json.
- [MCP server](https://viborm.dev/mcp): Streamable HTTP Model Context Protocol server with search_docs, get_page, list_pages, and get_navigation tools, plus every page as a resource. Discovery document: https://viborm.dev/.well-known/mcp.json
- [Agent skills](https://viborm.dev/.well-known/agent-skills/index.json): Agent Skills discovery index of the skills this site publishes.
- [API catalog](https://viborm.dev/.well-known/api-catalog): RFC 9727 linkset of the APIs documented here.
- [AI catalog](https://viborm.dev/.well-known/ai-catalog.json): ARD manifest of the agent-facing resources on this site (MCP server, skills, APIs).
- [agent-readability.json](https://viborm.dev/agent-readability.json): Manifest of every agent-facing artifact on this site.
- [Sitemap](https://viborm.dev/sitemap.xml): Every indexable page URL with its last-modified date.
