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.

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
  • 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: ^latest
ormed_sqlite: ^latest

dev_dependencies:
build_runner: ^2.4.0

Next Steps