Advanced Relations
Model complex relationships 1-1, 1-N, M-N, and even self-referential in a high-level, conceptual way.
Familiar Concepts
Inspired by popular ORMs in the Ruby, Python, and Node.js ecosystem, SeaORM offers a developer experience that feels instantly recognizable.
Feature Rich
SeaORM is a batteries-included ORM with filters, pagination, and nested queries to accelerate building REST, GraphQL, and gRPC APIs.
Production Ready
With 250k+ weekly downloads, SeaORM is production-ready, trusted by startups and enterprises worldwide.
Unique features of SeaORM
- Expressive Entity format
- Smart Entity Loader
- Nested ActiveModel
- Entity First Workflow
- Ergonomic Raw SQL
You don't have to write this by hand! Entity files can be generated from an existing database with sea-orm-cli.
use sea_orm::entity::prelude::*;#[sea_orm::model]#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]#[sea_orm(table_name = "user")]pub struct Model {#[sea_orm(primary_key)]pub id: i32,pub name: String,#[sea_orm(unique)]pub email: String,#[sea_orm(has_one)]pub profile: HasOne<super::profile::Entity>,#[sea_orm(has_many)]pub posts: HasMany<super::post::Entity>,}impl ActiveModelBehavior for ActiveModel {}
The Entity Loader intelligently uses join for 1-1 and data loader for 1-N relations, eliminating the N+1 problem even when performing nested queries.
// join paths:// user -> profile// user -> post// post -> post_tag -> taglet smart_user = user::Entity::load().filter_by_id(42) // shorthand for .filter(user::COLUMN.id.eq(42)).with(profile::Entity) // 1-1 uses join.with((post::Entity, tag::Entity)) // 1-N uses data loader.one(db).await?.unwrap();smart_user== user::ModelEx {id: 42,name: "Bob".into(),email: "bob@sea-ql.org".into(),profile: HasOne::Loaded(profile::ModelEx {picture: "image.jpg".into(),}.into()),posts: HasMany::Loaded(vec![post::ModelEx {title: "Nice weather".into(),tags: HasMany::Loaded(vec![tag::ModelEx {tag: "sunny".into(),}]),}]),};
Persist an entire object graph: user, profile (1-1), posts (1-N), and tags (M-N) in a single operation using a fluent builder API. SeaORM automatically determines the dependencies and inserts or deletes objects in the correct order.
let user = user::ActiveModel::builder().set_name("Bob").set_email("bob@sea-ql.org").set_profile(profile::ActiveModel::builder().set_picture("image.jpg")).add_post(post::ActiveModel::builder().set_title("Nice weather").add_tag(tag::ActiveModel::builder().set_tag("sunny")),).save(db).await?;
SeaORM 2.0 supports a first-class Entity First Workflow: simply define new entities or add columns to existing ones, and SeaORM will automatically detect the changes and create the new tables, columns, unique keys, and foreign keys.
// SeaORM resolves foreign key dependencies and creates the tables in topological order.// Requires the entity-registry and schema-sync feature flags.db.get_schema_registry("my_crate::entity::*").sync(db).await;
Let SeaORM handle 95% of your transactional queries. For the remaining cases that are too complex to express, SeaORM still offers convenient support for writing raw SQL.
let user = Item { name: "Bob" }; // nested parameter accesslet ids = [2, 3, 4]; // expanded by the .. operatorlet user: Option<user::Model> = user::Entity::find().from_raw_sql(raw_sql!(Sqlite,r#"SELECT "id", "name" FROM "user"WHERE "name" LIKE {user.name}AND "id" in ({..ids})"#)).one(db).await?;
SeaORM ➕ GraphQL = 🧭 Seaography
With Seaography, you can instantly launch a fully-fledged GraphQL server!

SeaORM ➕ React = 🖥️ SeaORM Pro
With SeaORM Pro, you can easily launch an admin panel for your application, frontend development skills not required!
Express your passion for Rust
The Rustacean Sticker Pack 🦀 are made with a premium water-resistant vinyl with a unique matte finish.
All proceeds contributes directly to open-source development.
Meet Terres, our official mascot
A friend of Ferris, Terres the hermit crab is a member of the Rustacean family.


















