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:
- Install dependencies from Installation.
- Run Quick Start in your project.
- 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:
- Install + first run: Installation -> Quick Start Existing app path: Adopt Existing Project
- Understand runtime setup: Configuration -> 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 - 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
- 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.2.0
ormed_sqlite: ^0.2.0
dev_dependencies:
build_runner: ^2.4.0
Then run:
dart pub get
dart run build_runner build
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 (SQLite, Postgres, MySQL, D1)