Getting Started
Datrix is a schema-driven database layer for TypeScript projects. Define your models, run migrations, and query your database — all within your existing application.
It is not a standalone server or a separate process. Datrix lives inside your codebase, works with your existing framework, and gives you full control over how and when it runs.
What Datrix provides
Schema system
Define your data models in TypeScript with full type inference. No magic strings, just code.
Migrations
Datrix diffs your schemas against the database and generates the necessary operations automatically.
CRUD API
Type-safe query interface with filtering, sorting, pagination and relation population out of the box.
datrix.findMany("user", {
where: { status: "active" },
populate: { profile: true }
})Plugin system
Extend Datrix with plugins for soft delete, hooks, HTTP API, and specialized behaviors.
CLI
Run migrations, generate schemas and types directly from your terminal with a robust toolset.
How it works
TypeScript objects describing your data models
datrix migrate syncs your database to your schemas
datrix.findMany(), datrix.create(), datrix.update(), ...
Prerequisites
PostgreSQL, MySQL, MongoDB, or JSON
Installation
# Core packages$pnpm add @datrix/core # CLI (dev dependency)$pnpm add -D @datrix/cli # Pick your adapter # PostgreSQL$pnpm add @datrix/adapter-postgres # PostgreSQL, driver-agnostic (bring your own pg driver)$pnpm add @datrix/adapter-postgres-core # MySQL / MariaDB$pnpm add @datrix/adapter-mysql # MongoDB$pnpm add @datrix/adapter-mongodb # JSON (local dev / testing)$pnpm add @datrix/adapter-json