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
- Migrations — Datrix diffs your schemas against the database and generates the necessary operations
- CRUD API — Type-safe query interface with filtering, sorting, pagination and relation population
- Plugin system — Extend Datrix with plugins (soft delete, hooks, HTTP API, and more)
- CLI — Run migrations, generate schemas and types from the command line
How it works
1. Define schemas → TypeScript objects describing your data models
2. Configure Datrix → defineConfig() with your adapter and schemas
3. Run migrations → datrix migrate syncs your database to your schemas
4. Query → datrix.findMany(), datrix.create(), datrix.update(), ...
Prerequisites
- Node.js 18 or later
- TypeScript 5.0 or later
- A supported database (PostgreSQL, MySQL, MongoDB, or JSON for local dev)
Installation
$# Core packages$pnpm add @datrix/core $# CLI (dev dependency)$pnpm add -D @datrix/cli $# Pick your adapter$pnpm add @datrix/adapter-postgres # PostgreSQL$pnpm add @datrix/adapter-mysql # MySQL / MariaDB$pnpm add @datrix/adapter-mongodb # MongoDB$pnpm add @datrix/adapter-json # JSON (local dev / testing)