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:
- Start with the database — Direct Database Access connects without code generation.
- Start with your domain — Installation 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:
- Pick a starting lane: Direct Database Access or Installation -> Quick Start Existing app path: Adopt Existing Project
- Understand runtime setup: Configuration -> DataSource -> Code Generation
- Model your domain: Models Overview -> Relationships
- Query and mutate data: Queries Overview -> Repository
- Evolve schema safely: Migrations Overview -> Running Migrations
- Choose deployment driver: Drivers Overview -> driver-specific pages
- 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 bootLearn Ormed: core model/query/migration mental modelDatabase Drivers: runtime-specific setup and behaviorBuild & Operate: CLI workflows and production guidesReference: capability docs and example index
Choose Your Path
- New project:
- Existing project:
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
- Model
- Query
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;
}
Future<void> introQueryExample(DataSource dataSource) async {
// Query with fluent API
final users = await dataSource
.query<$User>()
.whereEquals('active', true)
.orderBy('createdAt', descending: true)
.limit(10)
.get();
// Repository operations
final repo = dataSource.repo<$User>();
final user = await repo.find(1);
if (user != null) {
user.setAttribute('name', 'John');
await repo.update(user);
}
}
Installation
Add Ormed to your pubspec.yaml:
- pubspec.yaml
- Commands
dependencies:
ormed: ^0.4.0
ormed_sqlite: ^0.4.1
Then run:
dart pub get
Choose Direct Database Access if you do not need generated models yet. For generated models, add the tooling from Code Generation before continuing to Quick Start Guide.
Next Steps
- Quick Start Guide - Ship your first working query
- Models Overview - Move from toy data to real domain models
- Queries Overview - Build confidence with data access layers
- Migrations - Control schema changes confidently
- Drivers Overview - Pick the runtime target or Drift integration