一个强大且动态的 Rust ORM
[](https://crates.io/crates/sea-orm)
[](https://github.com/SeaQL/sea-orm/actions/workflows/rust.yml)
[](https://github.com/SeaQL/sea-orm/stargazers/)
请给我们一个 ⭐ 以支持我们!
# 🐚 SeaORM
SeaORM 是一个关系型 ORM,帮助你在 Rust 中构建 Web 服务,同时提供动态语言的使用体验。
### 高级关系
以高层次、概念化的方式建模复杂关系:一对一、一对多、多对多,甚至自引用。
### 熟悉的概念
受 Ruby、Python 和 Node.js 生态系统中流行 ORM 的启发,SeaORM 提供的开发体验让你感觉似曾相识。
### 功能丰富
SeaORM 是一个功能齐全的 ORM,内置过滤、分页和嵌套查询,加速构建 REST、GraphQL 和 gRPC API。
### 生产就绪
SeaORM 周下载量超过 25 万次,已被全球的初创企业和大型企业采用,适用于生产环境。
## 快速开始
[](https://discord.com/invite/uCPdDXzbdv)
加入我们的 Discord 服务器,与其他成员交流!
+ [中文文档](https://www.sea-ql.org/SeaORM/zh-CN/docs/index/)
集成示例:
+ [Actix 示例](https://github.com/SeaQL/sea-orm/tree/master/examples/actix_example)
+ [Axum 示例](https://github.com/SeaQL/sea-orm/tree/master/examples/axum_example)
+ [GraphQL 示例](https://github.com/SeaQL/sea-orm/tree/master/examples/graphql_example)
+ [jsonrpsee 示例](https://github.com/SeaQL/sea-orm/tree/master/examples/jsonrpsee_example)
+ [Loco 示例](https://github.com/SeaQL/sea-orm/tree/master/examples/loco_example) / [Loco REST 入门](https://github.com/SeaQL/sea-orm/tree/master/examples/loco_starter)
+ [Poem 示例](https://github.com/SeaQL/sea-orm/tree/master/examples/poem_example)
+ [Rocket 示例](https://github.com/SeaQL/sea-orm/tree/master/examples/rocket_example) / [Rocket OpenAPI 示例](https://github.com/SeaQL/sea-orm/tree/master/examples/rocket_okapi_example)
+ [Salvo 示例](https://github.com/SeaQL/sea-orm/tree/master/examples/salvo_example)
+ [Tonic 示例](https://github.com/SeaQL/sea-orm/tree/master/examples/tonic_example)
+ [Seaography 示例 (Bakery)](https://github.com/SeaQL/sea-orm/tree/master/examples/seaography_example) / [Seaography 示例 (Sakila)](https://github.com/SeaQL/seaography/tree/main/examples/sqlite)
如果你想要一个简洁的单文件示例来展示 SeaORM 的精华,可以试试:
+ [快速入门](https://github.com/SeaQL/sea-orm/blob/master/examples/quickstart/src/main.rs)
让我们快速了解一下 SeaORM 的独特功能。
## 灵活的实体格式
你不需要手写这些!实体文件可以使用 `sea-orm-cli` 从现有数据库生成,
以下代码通过 `--entity-format dense` 生成 *(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