+2
Daily
9,970
stars
749
forks
38
watchers
1,206
prs
1,094
issues
106
releases
README
SeaORM is a powerful ORM for building web services in Rust
Support us with a ⭐ !
🐚 SeaORM
中文文档
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.
TLS configuration
SeaORM's default features do not enable TLS. To select a TLS backend for SQLx, you need to add a SQLx dependency with the desired TLS feature.
For example, to use sqlx-postgres with tokio and AWS-LC:
toml
[dependencies]
sea-orm = { version = "2", features = ["sqlx-postgres", "runtime-tokio"] }
sqlx = { version = "0.9", features = ["tls-rustls-aws-lc-rs"] }
When using sea-orm-cli as a dependency, its defaults enable runtime-tokio-native-tls. To select another TLS backend, you need to disable the default features:
toml
[dependencies]
sea-orm-cli = { version = "2", default-features = false, features = [
"codegen",
"sqlx-postgres",
"runtime-tokio",
] }
sqlx = { version = "0.9", features = ["tls-rustls-aws-lc-rs"] }
Getting Started
Join our Discord server to chat with others!
+ Documentation
Integration examples:
+ Actix Example
+ Axum Example
+ GraphQL Example
+ jsonrpsee Example
+ Loco Example / Loco REST Starter
+ Poem Example
+ Rocket Example / Rocket OpenAPI Example
+ Salvo Example
+ Tonic Example
+ Seaography Example (Bakery) / Seaography Example (Sakila)
If you want a simple, clean example that fits in a single file that demonstrates the best of SeaORM, you can try:
+ Quickstart
Let's have a quick walk through of the unique features of SeaORM.
Expressive Entity format
You don't have to write this by hand! Entity files can be generated from an existing database using sea-orm-cli,
following is generated with --entity-format dense (new in 2.0).
rust
mod user {
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,
[sea_orm(has_many)]
pub posts: HasMany,
}
}
mod post {
use sea_orm::entity::prelude::;
[sea_orm::model]
[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
[sea_orm(table_name = "post")]
pub struct Model {
[sea_orm(primary_key)]
pub id: i32,
pub user_id: i32,
pub title: String,
[sea_orm(belongs_to, from = "user_id", to = "id")]
pub autTop issues
#220[Feature Request] Soft Delete18 comments · 2021-10-03#924Uuid/Datetime/etc. types (instead of String) for generated models with sqlite databases14 comments · 2022-07-29#1123[PIP] Event stream12 comments · 2022-10-16#2423Returning model with `enum` field with `find_by_statement`10 comments · 2024-11-20#591[ADD]: Pre-commit hook to keep the project clean10 comments · 2022-03-10#3183Nested ActiveModelEx::save() fails to insert a new has_many child with a composite, non-auto-increment primary key9 comments · 2026-08-22#3034Postgres tsvector/tsquery support9 comments · 2026-04-02#2749Feature Request: Support for async closures9 comments · 2025-10-12
Discussions
#3262camelCase for custom query and mutation names1 comments · 2026-11-11#3260Specify rs_type on generated enum1 comments · 2026-11-10#3239How to mock Entity Loader-type queries? (Or, examples on how to mock complex relationships?)2 comments · 2026-10-23#3230From `DeriveIntoActiveModel` to a Rust MapStruct: should SeaORM add `DeriveIntoVo` or incubate a dedicated mapper?2 comments · 2026-10-10#3223Invite more contributors and maintainers to help SesQL grow1 comments · 2026-10-05#3190manage migration files in entity firs aproach, verify them, apply them either using seaorm migration files or flyway1 comments · 2026-09-01#3181Updating ActiveModel with deeply nested ActiveModel structure after the fact2 comments · 2026-08-21#3170Why is `Eq` skipped in `ModelEx`?1 comments · 2026-08-13
Latest release
2.0.4 2.0.4 2026-09-27SeaORM 2.0.4
(since 2.0.3)
Enhancements
Add select_except to select all columns except the given ones https://github.com/SeaQL/sea-orm/pull/3211
select_except provides the inverse of select_only / column——selecting all columns except the specified ones.
These methods replace the current selection, so the last one called takes effect.
rust
[derive(DerivePartialModel)]
[sea_orm(entity = "post::Entity")]
struct PostPreview {
id: i32,
title: String,
}
let posts = post::Entity::find()
.select_except([post::Column::Body])
.into_model::()
.all(db