Skip to main content

Introduction

Ormed is a strongly-typed ORM for Dart that stays useful before and after code generation. Connect directly to a driver for raw SQL and ad-hoc tables, then add generated models when your domain needs stronger contracts.

Before you start: Basic Dart familiarity.

First 15 Minutes

If you want the shortest path to a running query, choose one of these lanes:

  1. Start with the databaseDirect Database Access connects without code generation.
  2. Start with your domainInstallation and Quick Start scaffold generated models.

Both paths meet at DataSource, Query Builder, and the same driver adapters.

Use Adopt Existing Project instead of Quick Start if your app already has an established schema/runtime.

Learning Path

Follow this order to go from first contact to fluent usage:

  1. Pick a starting lane: Direct Database Access or Installation -> Quick Start Existing app path: Adopt Existing Project
  2. Understand runtime setup: Configuration -> DataSource -> Code Generation
  3. Model your domain: Models Overview -> Relationships
  4. Query and mutate data: Queries Overview -> Repository
  5. Evolve schema safely: Migrations Overview -> Running Migrations
  6. Choose deployment driver: Drivers Overview -> driver-specific pages
  7. Operational fluency: Guides Overview, then Testing + Observability

How The Docs Are Organized

The docs are intentionally split by learning mode, similar to mature framework docs:

  • Start Here: first successful setup and runtime boot
  • Learn Ormed: core model/query/migration mental model
  • Database Drivers: runtime-specific setup and behavior
  • Build & Operate: CLI workflows and production guides
  • Reference: capability docs and example index

Choose Your Path

Features

  • Type-safe queries - Fluent query builder with compile-time type checking
  • Code generation when you want it - Automatic generation of model definitions, codecs, and helpers
  • Driver-first boot - Connect, migrate, query, and run raw SQL without generated code
  • Flexible input handling - Accept tracked models, DTOs, or raw maps for CRUD operations
  • Relationship support - hasOne, hasMany, belongsTo, belongsToMany with eager/lazy loading
  • Soft deletes - Built-in support for soft delete patterns
  • Timestamps - Automatic timestamp management for created_at/updated_at
  • Migrations - Fluent schema builder with reversible migrations
  • Multi-database - Support for SQLite, PostgreSQL, MySQL, and D1
  • Drift integration - Share a Drift executor with Ormed queries and reactive watchers
  • Value codecs - Custom type serialization between Dart and database
  • Observability - Ordered query interceptors and a built-in Dartastic OpenTelemetry adapter

Quick Example

import 'package:ormed/ormed.dart';

part 'user.orm.dart';

(table: 'users')
class User extends Model<User> {
const User({
required this.id,
required this.email,
this.name,
this.createdAt,
});

(isPrimaryKey: true, autoIncrement: true)
final int id;

final String email;
final String? name;
final DateTime? createdAt;
}

Installation

Add Ormed to your pubspec.yaml:

dependencies:
ormed: ^0.4.0
ormed_sqlite: ^0.4.1

Next Steps