Skip to main content

Introduction

Ormed is a strongly-typed ORM for Dart inspired by GORM, SQLAlchemy, and ActiveRecord-style patterns. It combines compile-time code generation with runtime flexibility to deliver type-safe database operations.

Prerequisites

  • Basic Dart familiarity

What You’ll Learn

  • What Ormed is and where it fits in a Dart stack
  • The recommended path from first setup to advanced usage
  • Which sections to use for day-1 onboarding vs deeper reference work

First 15 Minutes

If you want the shortest path to a running query, do this:

  1. Install dependencies from Installation.
  2. Run Quick Start in your project.
  3. Use DataSource and Query Builder docs once your first query runs.

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. Install + first run: Installation -> Quick Start Existing app path: Adopt Existing Project
  2. Understand runtime setup: Configuration -> 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 - Automatic generation of model definitions, codecs, and helpers
  • 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
  • Value codecs - Custom type serialization between Dart and database

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.2.0
ormed_sqlite: ^0.2.0

dev_dependencies:
build_runner: ^2.4.0

Next Steps