{"id":14969032,"url":"https://github.com/seaql/sea-orm","last_synced_at":"2025-09-09T20:11:39.577Z","repository":{"id":36978735,"uuid":"337322967","full_name":"SeaQL/sea-orm","owner":"SeaQL","description":"🐚 An async \u0026 dynamic ORM for Rust","archived":false,"fork":false,"pushed_at":"2025-05-02T12:42:28.000Z","size":17804,"stargazers_count":8146,"open_issues_count":192,"forks_count":568,"subscribers_count":37,"default_branch":"master","last_synced_at":"2025-05-05T11:47:54.137Z","etag":null,"topics":["database","hacktoberfest","loco","mariadb","mysql","orm","postgres","rust","sql","sqlite","sqlx","tokio"],"latest_commit_sha":null,"homepage":"https://www.sea-ql.org/SeaORM/","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SeaQL.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"SeaQL"}},"created_at":"2021-02-09T07:16:15.000Z","updated_at":"2025-05-05T09:22:54.000Z","dependencies_parsed_at":"2023-10-12T18:56:16.402Z","dependency_job_id":"be2e31a5-6b0b-4b00-84ea-8fb043664315","html_url":"https://github.com/SeaQL/sea-orm","commit_stats":{"total_commits":2473,"total_committers":217,"mean_commits":"11.396313364055299","dds":0.6639708855640922,"last_synced_commit":"647c93c46435392df3995c7187e72c99d213909f"},"previous_names":[],"tags_count":81,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SeaQL%2Fsea-orm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SeaQL%2Fsea-orm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SeaQL%2Fsea-orm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SeaQL%2Fsea-orm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SeaQL","download_url":"https://codeload.github.com/SeaQL/sea-orm/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252504159,"owners_count":21758654,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["database","hacktoberfest","loco","mariadb","mysql","orm","postgres","rust","sql","sqlite","sqlx","tokio"],"created_at":"2024-09-24T13:40:59.279Z","updated_at":"2025-09-09T20:11:39.570Z","avatar_url":"https://github.com/SeaQL.png","language":"Rust","funding_links":["https://github.com/sponsors/SeaQL"],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n  \u003cimg src=\"https://www.sea-ql.org/SeaORM/img/SeaORM banner.png\"/\u003e\n\n  \u003ch1\u003eSeaORM\u003c/h1\u003e\n\n  \u003ch3\u003e🐚 An async \u0026 dynamic ORM for Rust\u003c/h3\u003e\n\n  [![crate](https://img.shields.io/crates/v/sea-orm.svg)](https://crates.io/crates/sea-orm)\n  [![docs](https://docs.rs/sea-orm/badge.svg)](https://docs.rs/sea-orm)\n  [![build status](https://github.com/SeaQL/sea-orm/actions/workflows/rust.yml/badge.svg)](https://github.com/SeaQL/sea-orm/actions/workflows/rust.yml)\n\n\u003c/div\u003e\n\n# SeaORM\n\n[中文文档](https://github.com/SeaQL/sea-orm/blob/master/README-zh.md)\n\n#### SeaORM is a relational ORM to help you build web services in Rust with the familiarity of dynamic languages.\n\n[![GitHub stars](https://img.shields.io/github/stars/SeaQL/sea-orm.svg?style=social\u0026label=Star\u0026maxAge=1)](https://github.com/SeaQL/sea-orm/stargazers/)\nIf you like what we do, consider starring, sharing and contributing!\n\nPlease help us with maintaining SeaORM by completing the [SeaQL Community Survey 2025](https://www.sea-ql.org/community-survey/)!\n\n[![Discord](https://img.shields.io/discord/873880840487206962?label=Discord)](https://discord.com/invite/uCPdDXzbdv)\nJoin our Discord server to chat with other members of the SeaQL community!\n\n## Getting Started\n\n+ [Documentation](https://www.sea-ql.org/SeaORM)\n+ [Tutorial](https://www.sea-ql.org/sea-orm-tutorial)\n+ [Cookbook](https://www.sea-ql.org/sea-orm-cookbook)\n\nIntegration examples:\n\n+ [Actix v4 Example](https://github.com/SeaQL/sea-orm/tree/master/examples/actix_example)\n+ [Axum Example](https://github.com/SeaQL/sea-orm/tree/master/examples/axum_example)\n+ [GraphQL Example](https://github.com/SeaQL/sea-orm/tree/master/examples/graphql_example)\n+ [jsonrpsee Example](https://github.com/SeaQL/sea-orm/tree/master/examples/jsonrpsee_example)\n+ [Loco TODO Example](https://github.com/SeaQL/sea-orm/tree/master/examples/loco_example) / [Loco REST Starter](https://github.com/SeaQL/sea-orm/tree/master/examples/loco_starter)\n+ [Poem Example](https://github.com/SeaQL/sea-orm/tree/master/examples/poem_example)\n+ [Rocket Example](https://github.com/SeaQL/sea-orm/tree/master/examples/rocket_example) / [Rocket OpenAPI Example](https://github.com/SeaQL/sea-orm/tree/master/examples/rocket_okapi_example)\n+ [Salvo Example](https://github.com/SeaQL/sea-orm/tree/master/examples/salvo_example)\n+ [Tonic Example](https://github.com/SeaQL/sea-orm/tree/master/examples/tonic_example)\n+ [Seaography Example (Bakery)](https://github.com/SeaQL/sea-orm/tree/master/examples/seaography_example) / [Seaography Example (Sakila)](https://github.com/SeaQL/seaography/tree/main/examples/sqlite)\n\n## Features\n\n1. Async\n\n    Relying on [SQLx](https://github.com/launchbadge/sqlx), SeaORM is a new library with async support from day 1.\n\n2. Dynamic\n\n    Built upon [SeaQuery](https://github.com/SeaQL/sea-query), SeaORM allows you to build complex dynamic queries.\n\n3. Service Oriented\n\n    Quickly build services that join, filter, sort and paginate data in REST, GraphQL and gRPC APIs.\n\n4. Production Ready\n\n    SeaORM is feature-rich, well-tested and used in production by companies and startups.\n\n## A quick taste of SeaORM\n\n### Entity\n```rust\nuse sea_orm::entity::prelude::*;\n\n#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]\n#[sea_orm(table_name = \"cake\")]\npub struct Model {\n    #[sea_orm(primary_key)]\n    pub id: i32,\n    pub name: String,\n}\n\n#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]\npub enum Relation {\n    #[sea_orm(has_many = \"super::fruit::Entity\")]\n    Fruit,\n}\n\nimpl Related\u003csuper::fruit::Entity\u003e for Entity {\n    fn to() -\u003e RelationDef {\n        Relation::Fruit.def()\n    }\n}\n```\n\n### Select\n```rust\n// find all models\nlet cakes: Vec\u003ccake::Model\u003e = Cake::find().all(db).await?;\n\n// find and filter\nlet chocolate: Vec\u003ccake::Model\u003e = Cake::find()\n    .filter(cake::Column::Name.contains(\"chocolate\"))\n    .all(db)\n    .await?;\n\n// find one model\nlet cheese: Option\u003ccake::Model\u003e = Cake::find_by_id(1).one(db).await?;\nlet cheese: cake::Model = cheese.unwrap();\n\n// find related models (lazy)\nlet fruits: Vec\u003cfruit::Model\u003e = cheese.find_related(Fruit).all(db).await?;\n\n// find related models (eager)\nlet cake_with_fruits: Vec\u003c(cake::Model, Vec\u003cfruit::Model\u003e)\u003e =\n    Cake::find().find_with_related(Fruit).all(db).await?;\n```\n\n### Nested Select\n\n```rust\nuse sea_orm::DerivePartialModel;\n\n#[derive(DerivePartialModel)]\n#[sea_orm(entity = \"cake::Entity\")]\nstruct CakeWithFruit {\n    id: i32,\n    name: String,\n    #[sea_orm(nested)]\n    fruit: Option\u003cfruit::Model\u003e,\n}\n\nlet cakes: Vec\u003cCakeWithFruit\u003e = cake::Entity::find()\n    .left_join(fruit::Entity)\n    .into_partial_model()\n    .all(db)\n    .await?;\n```\n\n### Insert\n```rust\nlet apple = fruit::ActiveModel {\n    name: Set(\"Apple\".to_owned()),\n    ..Default::default() // no need to set primary key\n};\n\nlet pear = fruit::ActiveModel {\n    name: Set(\"Pear\".to_owned()),\n    ..Default::default()\n};\n\n// insert one\nlet pear = pear.insert(db).await?;\n\n// insert many returning last insert id\nlet result = Fruit::insert_many([apple, pear]).exec(db).await?;\nresult.last_insert_id == Some(2);\n```\n\n### Insert (advanced)\n```rust\n// insert many with returning (if supported by database)\nlet models: Vec\u003cfruit::Model\u003e = Fruit::insert_many([apple, pear])\n    .exec_with_returning(db)\n    .await?;\nmodels[0]\n    == fruit::Model {\n        id: 1,\n        name: \"Apple\".to_owned(),\n        cake_id: None,\n    };\n\n// insert with ON CONFLICT on primary key do nothing, with MySQL specific polyfill\nlet result = Fruit::insert_many([apple, pear])\n    .on_conflict_do_nothing()\n    .exec(db)\n    .await?;\n\nmatches!(result, TryInsertResult::Conflicted);\n```\n\n### Update\n```rust\nuse sea_orm::sea_query::{Expr, Value};\n\nlet pear: Option\u003cfruit::Model\u003e = Fruit::find_by_id(1).one(db).await?;\nlet mut pear: fruit::ActiveModel = pear.unwrap().into();\n\npear.name = Set(\"Sweet pear\".to_owned());\n\n// update one\nlet pear: fruit::Model = pear.update(db).await?;\n\n// update many: UPDATE \"fruit\" SET \"cake_id\" = NULL WHERE \"fruit\".\"name\" LIKE '%Apple%'\nFruit::update_many()\n    .col_expr(fruit::Column::CakeId, Expr::value(Value::Int(None)))\n    .filter(fruit::Column::Name.contains(\"Apple\"))\n    .exec(db)\n    .await?;\n\n```\n### Save\n```rust\nlet banana = fruit::ActiveModel {\n    id: NotSet,\n    name: Set(\"Banana\".to_owned()),\n    ..Default::default()\n};\n\n// create, because primary key `id` is `NotSet`\nlet mut banana = banana.save(db).await?;\n\nbanana.name = Set(\"Banana Mongo\".to_owned());\n\n// update, because primary key `id` is `Set`\nlet banana = banana.save(db).await?;\n\n```\n### Delete\n```rust\n// delete one\nlet orange: Option\u003cfruit::Model\u003e = Fruit::find_by_id(1).one(db).await?;\nlet orange: fruit::Model = orange.unwrap();\nfruit::Entity::delete(orange.into_active_model())\n    .exec(db)\n    .await?;\n\n// or simply\nlet orange: Option\u003cfruit::Model\u003e = Fruit::find_by_id(1).one(db).await?;\nlet orange: fruit::Model = orange.unwrap();\norange.delete(db).await?;\n\n// delete many: DELETE FROM \"fruit\" WHERE \"fruit\".\"name\" LIKE 'Orange'\nfruit::Entity::delete_many()\n    .filter(fruit::Column::Name.contains(\"Orange\"))\n    .exec(db)\n    .await?;\n\n```\n### Raw SQL\n```rust\n#[derive(FromQueryResult)]\nstruct Cake {\n    name: String,\n    #[sea_orm(nested)]\n    bakery: Option\u003cBakery\u003e,\n}\n\n#[derive(FromQueryResult)]\nstruct Bakery {\n    #[sea_orm(alias = \"bakery_name\")]\n    name: String,\n}\n\nlet cake_ids = [2, 3, 4]; // expanded by the `..` operator\n\nlet cake: Option\u003cCake\u003e = Cake::find_by_statement(raw_sql!(\n    Sqlite,\n    r#\"SELECT \"cake\".\"name\", \"bakery\".\"name\" AS \"bakery_name\"\n       FROM \"cake\"\n       LEFT JOIN \"bakery\" ON \"cake\".\"bakery_id\" = \"bakery\".\"id\"\n       WHERE \"cake\".\"id\" IN ({..cake_ids})\"#\n))\n.one(db)\n.await?;\n```\n\n## 🧭 Seaography: instant GraphQL API\n\n[Seaography](https://github.com/SeaQL/seaography) is a GraphQL framework built on top of SeaORM. Seaography allows you to build GraphQL resolvers quickly. With just a few commands, you can launch a GraphQL server from SeaORM entities!\n\nLook at the [Seaography Example](https://github.com/SeaQL/sea-orm/tree/master/examples/seaography_example) to learn more.\n\n\u003cimg src=\"https://raw.githubusercontent.com/SeaQL/sea-orm/master/examples/seaography_example/Seaography%20example.png\"/\u003e\n\n## 🖥️ SeaORM Pro: Professional Admin Panel\n\n[SeaORM Pro](https://www.sea-ql.org/sea-orm-pro/) is an admin panel solution allowing you to quickly and easily launch an admin panel for your application - frontend development skills not required, but certainly nice to have!\n\nFeatures:\n\n+ Full CRUD\n+ Built on React + GraphQL\n+ Built-in GraphQL resolver\n+ Customize the UI with simple TOML\n\nLearn More\n\n+ [Example Repo](https://github.com/SeaQL/sea-orm-pro)\n+ [Getting Started with Loco](https://www.sea-ql.org/sea-orm-pro/docs/install-and-config/getting-started-loco/)\n+ [Getting Started with Axum](https://www.sea-ql.org/sea-orm-pro/docs/install-and-config/getting-started-axum/)\n\n![](https://raw.githubusercontent.com/SeaQL/sea-orm/refs/heads/master/docs/sea-orm-pro-dark.png#gh-dark-mode-only)\n![](https://raw.githubusercontent.com/SeaQL/sea-orm/refs/heads/master/docs/sea-orm-pro-light.png#gh-light-mode-only)\n\n## Releases\n\n[SeaORM 1.0](https://www.sea-ql.org/blog/2024-08-04-sea-orm-1.0/) is a stable release. The 1.x version will be updated until at least October 2025, and we'll decide whether to release a 2.0 version or extend the 1.x life cycle.\n\nIt doesn't mean that SeaORM is 'done', we've designed an architecture to allow us to deliver new features without major breaking changes. In fact, more features are coming!\n\n+ [Change Log](https://github.com/SeaQL/sea-orm/tree/master/CHANGELOG.md)\n\n### Who's using SeaORM?\n\nHere is a short list of awesome open source software built with SeaORM. [Full list here](https://github.com/SeaQL/sea-orm/blob/master/COMMUNITY.md#built-with-seaorm). Feel free to submit yours!\n\n| Project | GitHub | Tagline |\n|---------|--------|---------|\n| [Zed](https://github.com/zed-industries/zed) | ![GitHub stars](https://img.shields.io/github/stars/zed-industries/zed.svg?style=social) | A high-performance, multiplayer code editor |\n| [OpenObserve](https://github.com/openobserve/openobserve) | ![GitHub stars](https://img.shields.io/github/stars/openobserve/openobserve.svg?style=social) | Open-source observability platform |\n| [RisingWave](https://github.com/risingwavelabs/risingwave) | ![GitHub stars](https://img.shields.io/github/stars/risingwavelabs/risingwave.svg?style=social) | Stream processing and management platform |\n| [LLDAP](https://github.com/nitnelave/lldap) | ![GitHub stars](https://img.shields.io/github/stars/nitnelave/lldap.svg?style=social) | A light LDAP server for user management |\n| [Warpgate](https://github.com/warp-tech/warpgate) | ![GitHub stars](https://img.shields.io/github/stars/warp-tech/warpgate.svg?style=social) | Smart SSH bastion that works with any SSH client |\n| [Svix](https://github.com/svix/svix-webhooks) | ![GitHub stars](https://img.shields.io/github/stars/svix/svix-webhooks.svg?style=social) | The enterprise ready webhooks service |\n| [Ryot](https://github.com/IgnisDa/ryot) | ![GitHub stars](https://img.shields.io/github/stars/ignisda/ryot.svg?style=social) | The only self hosted tracker you will ever need |\n| [Lapdev](https://github.com/lapce/lapdev) | ![GitHub stars](https://img.shields.io/github/stars/lapce/lapdev.svg?style=social) | Self-hosted remote development enviroment |\n| [System Initiative](https://github.com/systeminit/si) | ![GitHub stars](https://img.shields.io/github/stars/systeminit/si.svg?style=social) | DevOps Automation Platform |\n| [OctoBase](https://github.com/toeverything/OctoBase) | ![GitHub stars](https://img.shields.io/github/stars/toeverything/OctoBase.svg?style=social) | A light-weight, scalable, offline collaborative data backend |\n\n## License\n\nLicensed under either of\n\n-   Apache License, Version 2.0\n    ([LICENSE-APACHE](LICENSE-APACHE) or \u003chttp://www.apache.org/licenses/LICENSE-2.0\u003e)\n-   MIT license\n    ([LICENSE-MIT](LICENSE-MIT) or \u003chttp://opensource.org/licenses/MIT\u003e)\n\nat your option.\n\n## Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally submitted\nfor inclusion in the work by you, as defined in the Apache-2.0 license, shall be\ndual licensed as above, without any additional terms or conditions.\n\nWe invite you to participate, contribute and together help build Rust's future.\n\nA big shout out to our contributors!\n\n[![Contributors](https://opencollective.com/sea-orm/contributors.svg?width=1000\u0026button=false)](https://github.com/SeaQL/sea-orm/graphs/contributors)\n\n## Sponsorship\n\n[SeaQL.org](https://www.sea-ql.org/) is an independent open-source organization run by passionate developers. If you enjoy using our libraries, please star and share our repositories. If you feel generous, a small donation via [GitHub Sponsor](https://github.com/sponsors/SeaQL) will be greatly appreciated, and goes a long way towards sustaining the organization.\n\n### Gold Sponsors\n\n\u003ctable\u003e\u003ctr\u003e\n\u003ctd\u003e\u003ca href=\"https://qdx.co/\"\u003e\n  \u003cimg src=\"https://www.sea-ql.org/static/sponsors/QDX.svg\" width=\"138\"/\u003e\n\u003c/a\u003e\u003c/td\u003e\n\u003c/tr\u003e\u003c/table\u003e\n\n[QDX](https://qdx.co/) pioneers quantum dynamics-powered drug discovery, leveraging AI and supercomputing to accelerate molecular modeling.\nWe're immensely grateful to QDX for sponsoring the development of SeaORM, the SQL toolkit that powers their data engineering workflows.\n\n### Silver Sponsors\n\nWe’re grateful to our silver sponsors: Digital Ocean, for sponsoring our servers. And JetBrains, for sponsoring our IDE.\n\n\u003ctable\u003e\u003ctr\u003e\n\u003ctd\u003e\u003ca href=\"https://www.digitalocean.com/\"\u003e\n  \u003cimg src=\"https://www.sea-ql.org/static/sponsors/DigitalOcean.svg\" width=\"125\"\u003e\n\u003c/a\u003e\u003c/td\u003e\n\n\u003ctd\u003e\u003ca href=\"https://www.jetbrains.com/\"\u003e\n  \u003cimg src=\"https://www.sea-ql.org/static/sponsors/JetBrains.svg\" width=\"125\"\u003e\n\u003c/a\u003e\u003c/td\u003e\n\u003c/tr\u003e\u003c/table\u003e\n\n## Mascot\n\nA friend of Ferris, Terres the hermit crab is the official mascot of SeaORM. His hobby is collecting shells.\n\n\u003cimg alt=\"Terres\" src=\"https://www.sea-ql.org/SeaORM/img/Terres.png\" width=\"400\"/\u003e\n\n### Rustacean Sticker Pack 🦀\n\nThe Rustacean Sticker Pack is the perfect way to express your passion for Rust.\nOur stickers are made with a premium water-resistant vinyl with a unique matte finish.\nStick them on your laptop, notebook, or any gadget to show off your love for Rust!\n\nSticker Pack Contents:\n- Logo of SeaQL projects: SeaQL, SeaORM, SeaQuery, Seaography, FireDBG\n- Mascot of SeaQL: Terres the Hermit Crab\n- Mascot of Rust: Ferris the Crab\n- The Rustacean word\n\n[Support SeaQL and get a Sticker Pack!](https://www.sea-ql.org/sticker-pack/) All proceeds contributes directly to the ongoing development of SeaQL projects.\n\n\u003ca href=\"https://www.sea-ql.org/sticker-pack/\"\u003e\u003cimg alt=\"Rustacean Sticker Pack by SeaQL\" src=\"https://www.sea-ql.org/static/sticker-pack-1s.jpg\" width=\"600\"/\u003e\u003c/a\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseaql%2Fsea-orm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fseaql%2Fsea-orm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseaql%2Fsea-orm/lists"}