comon_orm is a schema-first ORM toolkit for Dart inspired by Prisma.
The core idea is simple: define your models in schema.prisma, generate a typed Dart client, apply the schema to the database through the migration flow, and work through the generated API instead of hand-written maps and raw SQL strings.
The workspace also includes an OpenTelemetry bridge package so query spans and database metrics can be exported through comon_otel.
Minimal schema.prisma:
datasource db {
provider = "sqlite"
url = "dev.db"
}
generator client {
provider = "comon_orm"
output = "lib/generated/comon_orm_client.dart"
}
model User {
id Int @id @default(autoincrement())
email String @unique
name String?
}Generate the client:
dart run comon_orm check
dart run comon_orm generateCreate and apply the first migration during development:
dart run comon_orm migrate dev --name initDeploy reviewed migrations in CI or production:
dart run comon_orm migrate deployPrototype quickly without migration files:
dart run comon_orm db pushUse the generated client in Dart:
import 'generated/comon_orm_client.dart';
Future<void> main() async {
final db = await ComonOrm.sqlite();
try {
final user = await db.user.create(
data: const UserCreateInput(
email: 'alice@example.com',
name: 'Alice',
),
);
final users = await db.user.findMany();
print(user.email);
print(users.length);
} finally {
await db.close();
}
}| Package | Purpose |
|---|---|
packages/comon_orm |
parser, validator, formatter, codegen, query models, in-memory adapter, migration metadata |
packages/comon_orm_otel |
OpenTelemetry middleware for ORM spans, transaction nesting, and database metrics |
packages/comon_orm_postgresql |
PostgreSQL runtime adapter, introspection, and migrations |
packages/comon_orm_sqlite |
SQLite runtime adapter, introspection, and rebuild-aware migrations |
packages/comon_orm_sqlite_flutter |
Flutter asset-backed migration loading plus shared sqlite runtime re-exports |
Detailed documentation now lives in the Fumadocs site under site/.
site/content/docs/coresite/content/docs/schemasite/content/docs/dartsite/content/docs/otelsite/content/docs/migrations
Bootstrap the workspace from the repository root:
dart pub get
dart run melos bootstrapCommon validation commands:
dart run melos run analyze
dart run melos run test
dart run melos run format
dart run melos run publish:dry-runSee CONTRIBUTING.md for setup, validation, and pull request expectations.
This repository is distributed under the MIT License. See LICENSE.