sea_orm/
lib.rs

1#![cfg_attr(docsrs, feature(doc_cfg))]
2#![warn(missing_docs)]
3#![deny(
4    missing_debug_implementations,
5    clippy::missing_panics_doc,
6    clippy::unwrap_used,
7    clippy::print_stderr,
8    clippy::print_stdout
9)]
10
11//! <div align="center">
12//!
13//!   <img src="https://www.sea-ql.org/SeaORM/img/SeaORM banner.png"/>
14//!
15//!   <h1>SeaORM</h1>
16//!
17//!   <h3>🐚 An async & dynamic ORM for Rust</h3>
18//!
19//!   [![crate](https://img.shields.io/crates/v/sea-orm.svg)](https://crates.io/crates/sea-orm)
20//!   [![docs](https://docs.rs/sea-orm/badge.svg)](https://docs.rs/sea-orm)
21//!   [![build status](https://github.com/SeaQL/sea-orm/actions/workflows/rust.yml/badge.svg)](https://github.com/SeaQL/sea-orm/actions/workflows/rust.yml)
22//!
23//! </div>
24//!
25//! # SeaORM
26//!
27//! [中文文档](https://github.com/SeaQL/sea-orm/blob/master/README-zh.md)
28//!
29//! #### SeaORM is a relational ORM to help you build web services in Rust with the familiarity of dynamic languages.
30//!
31//! [![GitHub stars](https://img.shields.io/github/stars/SeaQL/sea-orm.svg?style=social&label=Star&maxAge=1)](https://github.com/SeaQL/sea-orm/stargazers/)
32//! If you like what we do, consider starring, sharing and contributing!
33//!
34//! Please help us with maintaining SeaORM by completing the [SeaQL Community Survey 2025](https://www.sea-ql.org/community-survey/)!
35//!
36//! [![Discord](https://img.shields.io/discord/873880840487206962?label=Discord)](https://discord.com/invite/uCPdDXzbdv)
37//! Join our Discord server to chat with other members of the SeaQL community!
38//!
39//! ## Getting Started
40//!
41//! + [Documentation](https://www.sea-ql.org/SeaORM)
42//! + [Tutorial](https://www.sea-ql.org/sea-orm-tutorial)
43//! + [Cookbook](https://www.sea-ql.org/sea-orm-cookbook)
44//!
45//! Integration examples:
46//!
47//! + [Actix v4 Example](https://github.com/SeaQL/sea-orm/tree/master/examples/actix_example)
48//! + [Axum Example](https://github.com/SeaQL/sea-orm/tree/master/examples/axum_example)
49//! + [GraphQL Example](https://github.com/SeaQL/sea-orm/tree/master/examples/graphql_example)
50//! + [jsonrpsee Example](https://github.com/SeaQL/sea-orm/tree/master/examples/jsonrpsee_example)
51//! + [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)
52//! + [Poem Example](https://github.com/SeaQL/sea-orm/tree/master/examples/poem_example)
53//! + [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)
54//! + [Salvo Example](https://github.com/SeaQL/sea-orm/tree/master/examples/salvo_example)
55//! + [Tonic Example](https://github.com/SeaQL/sea-orm/tree/master/examples/tonic_example)
56//! + [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)
57//!
58//! ## Features
59//!
60//! 1. Async
61//!
62//!     Relying on [SQLx](https://github.com/launchbadge/sqlx), SeaORM is a new library with async support from day 1.
63//!
64//! 2. Dynamic
65//!
66//!     Built upon [SeaQuery](https://github.com/SeaQL/sea-query), SeaORM allows you to build complex dynamic queries.
67//!
68//! 3. Service Oriented
69//!
70//!     Quickly build services that join, filter, sort and paginate data in REST, GraphQL and gRPC APIs.
71//!
72//! 4. Production Ready
73//!
74//!     SeaORM is feature-rich, well-tested and used in production by companies and startups.
75//!
76//! ## A quick taste of SeaORM
77//!
78//! Let's have a quick walk through of the unique features of SeaORM.
79//!
80//! ### Entity
81//! You don't have to write this by hand! Entity files can be generated from an existing database with `sea-orm-cli`.
82//! ```
83//! # #[cfg(feature = "macros")]
84//! # mod entities {
85//! # mod fruit {
86//! # use sea_orm::entity::prelude::*;
87//! # #[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
88//! # #[sea_orm(table_name = "fruit")]
89//! # pub struct Model {
90//! #     #[sea_orm(primary_key)]
91//! #     pub id: i32,
92//! #     pub name: String,
93//! #     pub cake_id: Option<i32>,
94//! # }
95//! # #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
96//! # pub enum Relation {
97//! #     #[sea_orm(
98//! #         belongs_to = "super::cake::Entity",
99//! #         from = "Column::CakeId",
100//! #         to = "super::cake::Column::Id"
101//! #     )]
102//! #     Cake,
103//! # }
104//! # impl Related<super::cake::Entity> for Entity {
105//! #     fn to() -> RelationDef {
106//! #         Relation::Cake.def()
107//! #     }
108//! # }
109//! # impl ActiveModelBehavior for ActiveModel {}
110//! # }
111//! # mod cake {
112//! use sea_orm::entity::prelude::*;
113//!
114//! #[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
115//! #[sea_orm(table_name = "cake")]
116//! pub struct Model {
117//!     #[sea_orm(primary_key)]
118//!     pub id: i32,
119//!     pub name: String,
120//! }
121//!
122//! #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
123//! pub enum Relation {
124//!     #[sea_orm(has_many = "super::fruit::Entity")]
125//!     Fruit,
126//! }
127//!
128//! impl Related<super::fruit::Entity> for Entity {
129//!     fn to() -> RelationDef {
130//!         Relation::Fruit.def()
131//!     }
132//! }
133//! # impl ActiveModelBehavior for ActiveModel {}
134//! # }
135//! # }
136//! ```
137//!
138//! ### Select
139//! SeaORM models 1-N and M-N relationships at the Entity level,
140//! letting you traverse many-to-many links through a junction table in a single call.
141//! ```
142//! # use sea_orm::{DbConn, error::*, entity::*, query::*, tests_cfg::*};
143//! # async fn function(db: &DbConn) -> Result<(), DbErr> {
144//! // find all models
145//! let cakes: Vec<cake::Model> = Cake::find().all(db).await?;
146//!
147//! // find and filter
148//! let chocolate: Vec<cake::Model> = Cake::find()
149//!     .filter(cake::Column::Name.contains("chocolate"))
150//!     .all(db)
151//!     .await?;
152//!
153//! // find one model
154//! let cheese: Option<cake::Model> = Cake::find_by_id(1).one(db).await?;
155//! let cheese: cake::Model = cheese.unwrap();
156//!
157//! // find related models (lazy)
158//! let fruits: Vec<fruit::Model> = cheese.find_related(Fruit).all(db).await?;
159//!
160//! // find related models (eager): for 1-1 relations
161//! let cake_with_fruit: Vec<(cake::Model, Option<fruit::Model>)> =
162//!     Cake::find().find_also_related(Fruit).all(db).await?;
163//!
164//! // find related models (eager): works for both 1-N and M-N relations
165//! let cake_with_fruits: Vec<(cake::Model, Vec<fruit::Model>)> = Cake::find()
166//!     .find_with_related(Fruit) // for M-N relations, two joins are performed
167//!     .all(db) // rows are automatically consolidated by left entity
168//!     .await?;
169//! # Ok(())
170//! # }
171//! ```
172//!
173//! ### Nested Select
174//!
175//! Partial models prevent overfetching by letting you querying only the fields
176//! you need; it also makes writing deeply nested relational queries simple.
177//! ```
178//! # use sea_orm::{DbConn, error::*, entity::*, query::*, tests_cfg::*};
179//! # async fn function(db: &DbConn) -> Result<(), DbErr> {
180//! use sea_orm::DerivePartialModel;
181//!
182//! #[derive(DerivePartialModel)]
183//! #[sea_orm(entity = "cake::Entity")]
184//! struct CakeWithFruit {
185//!     id: i32,
186//!     name: String,
187//!     #[sea_orm(nested)]
188//!     fruit: Option<fruit::Model>, // this can be a regular or another partial model
189//! }
190//!
191//! let cakes: Vec<CakeWithFruit> = Cake::find()
192//!     .left_join(fruit::Entity) // no need to specify join condition
193//!     .into_partial_model() // only the columns in the partial model will be selected
194//!     .all(db)
195//!     .await?;
196//! # Ok(())
197//! # }
198//! ```
199//!
200//! ### Insert
201//! SeaORM's ActiveModel lets you work directly with Rust data structures and
202//! persist them through a simple API.
203//! It's easy to insert large batches of rows from different data sources.
204//! ```
205//! # use sea_orm::{DbConn, error::*, entity::*, query::*, tests_cfg::*};
206//! # async fn function(db: &DbConn) -> Result<(), DbErr> {
207//! let apple = fruit::ActiveModel {
208//!     name: Set("Apple".to_owned()),
209//!     ..Default::default() // no need to set primary key
210//! };
211//!
212//! let pear = fruit::ActiveModel {
213//!     name: Set("Pear".to_owned()),
214//!     ..Default::default()
215//! };
216//!
217//! // insert one: Active Record style
218//! let apple = apple.insert(db).await?;
219//! apple.id == 1;
220//! # let apple = fruit::ActiveModel {
221//! #     name: Set("Apple".to_owned()),
222//! #     ..Default::default() // no need to set primary key
223//! # };
224//!
225//! // insert one: repository style
226//! let result = Fruit::insert(apple).exec(db).await?;
227//! result.last_insert_id == 1;
228//! # let apple = fruit::ActiveModel {
229//! #     name: Set("Apple".to_owned()),
230//! #     ..Default::default() // no need to set primary key
231//! # };
232//!
233//! // insert many returning last insert id
234//! let result = Fruit::insert_many([apple, pear]).exec(db).await?;
235//! result.last_insert_id == Some(2);
236//! # Ok(())
237//! # }
238//! ```
239//!
240//! ### Insert (advanced)
241//! You can take advantage of database specific features to perform upsert and idempotent insert.
242//! ```
243//! # use sea_orm::{DbConn, TryInsertResult, error::*, entity::*, query::*, tests_cfg::*};
244//! # async fn function_1(db: &DbConn) -> Result<(), DbErr> {
245//! # let apple = fruit::ActiveModel {
246//! #     name: Set("Apple".to_owned()),
247//! #     ..Default::default() // no need to set primary key
248//! # };
249//! # let pear = fruit::ActiveModel {
250//! #     name: Set("Pear".to_owned()),
251//! #     ..Default::default()
252//! # };
253//! // insert many with returning (if supported by database)
254//! let models: Vec<fruit::Model> = Fruit::insert_many([apple, pear])
255//!     .exec_with_returning(db)
256//!     .await?;
257//! models[0]
258//!     == fruit::Model {
259//!         id: 1, // database assigned value
260//!         name: "Apple".to_owned(),
261//!         cake_id: None,
262//!     };
263//! # Ok(())
264//! # }
265//!
266//! # async fn function_2(db: &DbConn) -> Result<(), DbErr> {
267//! # let apple = fruit::ActiveModel {
268//! #     name: Set("Apple".to_owned()),
269//! #     ..Default::default() // no need to set primary key
270//! # };
271//! # let pear = fruit::ActiveModel {
272//! #     name: Set("Pear".to_owned()),
273//! #     ..Default::default()
274//! # };
275//! // insert with ON CONFLICT on primary key do nothing, with MySQL specific polyfill
276//! let result = Fruit::insert_many([apple, pear])
277//!     .on_conflict_do_nothing()
278//!     .exec(db)
279//!     .await?;
280//!
281//! matches!(result, TryInsertResult::Conflicted);
282//! # Ok(())
283//! # }
284//! ```
285//!
286//! ### Update
287//! ActiveModel avoids race conditions by updating only the fields you've changed,
288//! never overwriting untouched columns.
289//! You can also craft complex bulk update queries with a fluent query building API.
290//! ```
291//! # use sea_orm::{DbConn, error::*, entity::*, query::*, tests_cfg::*};
292//! use fruit::Column::CakeId;
293//! use sea_orm::sea_query::{Expr, Value};
294//!
295//! # async fn function(db: &DbConn) -> Result<(), DbErr> {
296//! let pear: Option<fruit::Model> = Fruit::find_by_id(1).one(db).await?;
297//! let mut pear: fruit::ActiveModel = pear.unwrap().into();
298//!
299//! pear.name = Set("Sweet pear".to_owned()); // update value of a single field
300//!
301//! // update one: only changed columns will be updated
302//! let pear: fruit::Model = pear.update(db).await?;
303//!
304//! // update many: UPDATE "fruit" SET "cake_id" = "cake_id" + 2
305//! //               WHERE "fruit"."name" LIKE '%Apple%'
306//! Fruit::update_many()
307//!     .col_expr(CakeId, Expr::col(CakeId).add(Expr::val(2)))
308//!     .filter(fruit::Column::Name.contains("Apple"))
309//!     .exec(db)
310//!     .await?;
311//! # Ok(())
312//! # }
313//! ```
314//! ### Save
315//! You can perform "insert or update" operation with ActiveModel, making it easy to compose transactional operations.
316//! ```
317//! # use sea_orm::{DbConn, error::*, entity::*, query::*, tests_cfg::*};
318//! # async fn function(db: &DbConn) -> Result<(), DbErr> {
319//! let banana = fruit::ActiveModel {
320//!     id: NotSet,
321//!     name: Set("Banana".to_owned()),
322//!     ..Default::default()
323//! };
324//!
325//! // create, because primary key `id` is `NotSet`
326//! let mut banana = banana.save(db).await?;
327//!
328//! banana.id == Unchanged(2);
329//! banana.name = Set("Banana Mongo".to_owned());
330//!
331//! // update, because primary key `id` is present
332//! let banana = banana.save(db).await?;
333//! # Ok(())
334//! # }
335//! ```
336//! ### Delete
337//! The same ActiveModel API consistent with insert and update.
338//! ```
339//! # use sea_orm::{DbConn, error::*, entity::*, query::*, tests_cfg::*};
340//! # async fn function(db: &DbConn) -> Result<(), DbErr> {
341//! // delete one: Active Record style
342//! let orange: Option<fruit::Model> = Fruit::find_by_id(1).one(db).await?;
343//! let orange: fruit::Model = orange.unwrap();
344//! orange.delete(db).await?;
345//!
346//! // delete one: repository style
347//! let orange = fruit::ActiveModel {
348//!     id: Set(2),
349//!     ..Default::default()
350//! };
351//! fruit::Entity::delete(orange).exec(db).await?;
352//!
353//! // delete many: DELETE FROM "fruit" WHERE "fruit"."name" LIKE '%Orange%'
354//! fruit::Entity::delete_many()
355//!     .filter(fruit::Column::Name.contains("Orange"))
356//!     .exec(db)
357//!     .await?;
358//!
359//! # Ok(())
360//! # }
361//! ```
362//! ### Ergonomic Raw SQL
363//! Let SeaORM handle 90% of all the transactional queries.
364//! When your query is too complex to express, SeaORM still offer convenience in writing raw SQL.
365//!
366//! The `raw_sql!` macro is like the `format!` macro but without the risk of SQL injection.
367//! It supports nested parameter interpolation, array and tuple expansion, and even repeating group,
368//! offering great flexibility in crafting complex queries.
369//!
370//! ```
371//! # use sea_orm::{DbErr, DbConn};
372//! # async fn function(db: &DbConn) -> Result<(), DbErr> {
373//! # use sea_orm::{entity::*, query::*, tests_cfg::*, raw_sql};
374//! # struct Item { id: i32 }
375//! let item = Item { id: 2 }; // nested parameter access
376//!
377//! let cake: Option<cake::Model> = Cake::find()
378//!     .from_raw_sql(raw_sql!(
379//!         Sqlite,
380//!         r#"SELECT "id", "name" FROM "cake" WHERE id = {item.id}"#
381//!     ))
382//!     .one(db)
383//!     .await?;
384//! # Ok(())
385//! # }
386//! ```
387//! ```
388//! # use sea_orm::{DbErr, DbConn};
389//! # async fn functio(db: &DbConn) -> Result<(), DbErr> {
390//! # use sea_orm::{query::*, FromQueryResult, raw_sql};
391//! #[derive(FromQueryResult)]
392//! struct CakeWithBakery {
393//!     name: String,
394//!     #[sea_orm(nested)]
395//!     bakery: Option<Bakery>,
396//! }
397//!
398//! #[derive(FromQueryResult)]
399//! struct Bakery {
400//!     #[sea_orm(alias = "bakery_name")]
401//!     name: String,
402//! }
403//!
404//! let cake_ids = [2, 3, 4]; // expanded by the `..` operator
405//!
406//! // can use many APIs with raw SQL, including nested select
407//! let cake: Option<CakeWithBakery> = CakeWithBakery::find_by_statement(raw_sql!(
408//!     Sqlite,
409//!     r#"SELECT "cake"."name", "bakery"."name" AS "bakery_name"
410//!        FROM "cake"
411//!        LEFT JOIN "bakery" ON "cake"."bakery_id" = "bakery"."id"
412//!        WHERE "cake"."id" IN ({..cake_ids})"#
413//! ))
414//! .one(db)
415//! .await?;
416//! # Ok(())
417//! # }
418//! ```
419//!
420//! ## 🧭 Seaography: instant GraphQL API
421//!
422//! [Seaography](https://github.com/SeaQL/seaography) is a GraphQL framework built for SeaORM.
423//! Seaography allows you to build GraphQL resolvers quickly.
424//! With just a few commands, you can launch a fullly-featured GraphQL server from SeaORM entities,
425//! complete with filter, pagination, relational queries and mutations!
426//!
427//! Look at the [Seaography Example](https://github.com/SeaQL/sea-orm/tree/master/examples/seaography_example) to learn more.
428//!
429//! <img src="https://raw.githubusercontent.com/SeaQL/sea-orm/master/examples/seaography_example/Seaography%20example.png"/>
430//!
431//! ## 🖥️ SeaORM Pro: Professional Admin Panel
432//!
433//! [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!
434//!
435//! SeaORM Pro will be updated to support the latest features in SeaORM 2.0.
436//!
437//! Features:
438//!
439//! + Full CRUD
440//! + Built on React + GraphQL
441//! + Built-in GraphQL resolver
442//! + Customize the UI with TOML config
443//! + Custom GraphQL endpoints *(new in 2.0)*
444//! + Role Based Access Control *(new in 2.0)*
445//!
446//! Learn More
447//!
448//! + [Example Repo](https://github.com/SeaQL/sea-orm-pro)
449//! + [Getting Started with Loco](https://www.sea-ql.org/sea-orm-pro/docs/install-and-config/getting-started-loco/)
450//! + [Getting Started with Axum](https://www.sea-ql.org/sea-orm-pro/docs/install-and-config/getting-started-axum/)
451//!
452//! ![](https://raw.githubusercontent.com/SeaQL/sea-orm/refs/heads/master/docs/sea-orm-pro-dark.png#gh-dark-mode-only)
453//! ![](https://raw.githubusercontent.com/SeaQL/sea-orm/refs/heads/master/docs/sea-orm-pro-light.png#gh-light-mode-only)
454//!
455//! ## SQL Server Support
456//!
457//! [SQL Server for SeaORM](https://www.sea-ql.org/SeaORM-X/) offers the same SeaORM API for MSSQL. We ported all test cases and examples, complemented by MSSQL specific documentation. If you are building enterprise software, you can [request commercial access](https://forms.office.com/r/1MuRPJmYBR). It is currently based on SeaORM 1.0, but we will offer free upgrade to existing users when SeaORM 2.0 is finalized.
458//!
459//! ## Releases
460//!
461//! SeaORM 2.0 has reached its release candidate phase. We'd love for you to try it out and help shape the final release by [sharing your feedback](https://github.com/SeaQL/sea-orm/discussions/2548).
462//!
463//! SeaORM 2.0 is shaping up to be our most significant release yet - with a few breaking changes, plenty of enhancements, and a clear focus on developer experience.
464//!
465//! + [A Sneak Peek at SeaORM 2.0](https://www.sea-ql.org/blog/2025-09-16-sea-orm-2.0/)
466//! + [SeaORM 2.0: A closer look](https://www.sea-ql.org/blog/2025-09-24-sea-orm-2.0/)
467//!
468//! If you make extensive use of SeaORM's underlying query builder, we recommend checking out our blog post on SeaQuery 1.0 release:
469//!
470//! + [The road to SeaQuery 1.0](https://www.sea-ql.org/blog/2025-08-30-sea-query-1.0/)
471//!
472//! It doesn't mean that SeaORM is 'done', we've designed an architecture to allow us to deliver new features without major breaking changes.
473//!
474//! + [Change Log](https://github.com/SeaQL/sea-orm/tree/master/CHANGELOG.md)
475//!
476//! ## License
477//!
478//! Licensed under either of
479//!
480//! -   Apache License, Version 2.0
481//!     ([LICENSE-APACHE](LICENSE-APACHE) or <http://www.apache.org/licenses/LICENSE-2.0>)
482//! -   MIT license
483//!     ([LICENSE-MIT](LICENSE-MIT) or <http://opensource.org/licenses/MIT>)
484//!
485//! at your option.
486//!
487//! ## Contribution
488//!
489//! Unless you explicitly state otherwise, any contribution intentionally submitted
490//! for inclusion in the work by you, as defined in the Apache-2.0 license, shall be
491//! dual licensed as above, without any additional terms or conditions.
492//!
493//! We invite you to participate, contribute and together help build Rust's future.
494//!
495//! A big shout out to our contributors!
496//!
497//! [![Contributors](https://opencollective.com/sea-orm/contributors.svg?width=1000&button=false)](https://github.com/SeaQL/sea-orm/graphs/contributors)
498//!
499//! ## Who's using SeaORM?
500//!
501//! SeaORM is trusted by companies and startups for both internal tools and public‑facing applications, thanks to its ergonomics and the familiarity it brings from dynamic languages.
502//! Built on async Rust, it combines high performance and a strong type system without sacrificing developer productivity.
503//!
504//! Here 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!
505//!
506//! | Project | GitHub | Tagline |
507//! |---------|--------|---------|
508//! | [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 |
509//! | [OpenObserve](https://github.com/openobserve/openobserve) | ![GitHub stars](https://img.shields.io/github/stars/openobserve/openobserve.svg?style=social) | Open-source observability platform |
510//! | [RisingWave](https://github.com/risingwavelabs/risingwave) | ![GitHub stars](https://img.shields.io/github/stars/risingwavelabs/risingwave.svg?style=social) | Stream processing and management platform |
511//! | [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 |
512//! | [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 |
513//! | [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 |
514//! | [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 |
515//! | [Lapdev](https://github.com/lapce/lapdev) | ![GitHub stars](https://img.shields.io/github/stars/lapce/lapdev.svg?style=social) | Self-hosted remote development enviroment |
516//! | [System Initiative](https://github.com/systeminit/si) | ![GitHub stars](https://img.shields.io/github/stars/systeminit/si.svg?style=social) | DevOps Automation Platform |
517//! | [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 |
518//!
519//! ## Sponsorship
520//!
521//! [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.
522//!
523//! ### Gold Sponsors
524//!
525//! <table><tr>
526//! <td><a href="https://qdx.co/">
527//!   <img src="https://www.sea-ql.org/static/sponsors/QDX.svg" width="138"/>
528//! </a></td>
529//! </tr></table>
530//!
531//! [QDX](https://qdx.co/) pioneers quantum dynamics-powered drug discovery, leveraging AI and supercomputing to accelerate molecular modeling.
532//! We're immensely grateful to QDX for sponsoring the development of SeaORM, the SQL toolkit that powers their data engineering workflows.
533//!
534//! ### Silver Sponsors
535//!
536//! We're grateful to our silver sponsors: Digital Ocean, for sponsoring our servers. And JetBrains, for sponsoring our IDE.
537//!
538//! <table><tr>
539//! <td><a href="https://www.digitalocean.com/">
540//!   <img src="https://www.sea-ql.org/static/sponsors/DigitalOcean.svg" width="125">
541//! </a></td>
542//!
543//! <td><a href="https://www.jetbrains.com/">
544//!   <img src="https://www.sea-ql.org/static/sponsors/JetBrains.svg" width="125">
545//! </a></td>
546//! </tr></table>
547//!
548//! ## Mascot
549//!
550//! A friend of Ferris, Terres the hermit crab is the official mascot of SeaORM. His hobby is collecting shells.
551//!
552//! <img alt="Terres" src="https://www.sea-ql.org/SeaORM/img/Terres.png" width="400"/>
553//!
554//! ### Rustacean Sticker Pack 🦀
555//!
556//! The Rustacean Sticker Pack is the perfect way to express your passion for Rust.
557//! Our stickers are made with a premium water-resistant vinyl with a unique matte finish.
558//! Stick them on your laptop, notebook, or any gadget to show off your love for Rust!
559//!
560//! Sticker Pack Contents:
561//! - Logo of SeaQL projects: SeaQL, SeaORM, SeaQuery, Seaography, FireDBG
562//! - Mascot of SeaQL: Terres the Hermit Crab
563//! - Mascot of Rust: Ferris the Crab
564//! - The Rustacean word
565//!
566//! [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.
567//!
568//! <a href="https://www.sea-ql.org/sticker-pack/"><img alt="Rustacean Sticker Pack by SeaQL" src="https://www.sea-ql.org/static/sticker-pack-1s.jpg" width="600"/></a>
569#![doc(
570    html_logo_url = "https://raw.githubusercontent.com/SeaQL/sea-query/master/docs/SeaQL icon dark.png"
571)]
572
573mod database;
574mod docs;
575mod driver;
576/// Module for the Entity type and operations
577pub mod entity;
578/// Error types for all database operations
579pub mod error;
580/// This module performs execution of queries on a Model or ActiveModel
581mod executor;
582/// Types and methods to perform metric collection
583pub mod metric;
584/// Types and methods to perform queries
585pub mod query;
586#[cfg(feature = "rbac")]
587#[cfg_attr(docsrs, doc(cfg(feature = "rbac")))]
588pub mod rbac;
589/// Types that defines the schemas of an Entity
590pub mod schema;
591/// Helpers for working with Value
592pub mod value;
593
594#[doc(hidden)]
595#[cfg(all(feature = "macros", feature = "tests-cfg"))]
596pub mod tests_cfg;
597mod util;
598
599pub use database::*;
600#[allow(unused_imports)]
601pub use driver::*;
602pub use entity::*;
603pub use error::*;
604pub use executor::*;
605pub use query::*;
606pub use schema::*;
607
608#[cfg(feature = "macros")]
609pub use sea_orm_macros::{
610    DeriveActiveEnum, DeriveActiveModel, DeriveActiveModelBehavior, DeriveColumn, DeriveDisplay,
611    DeriveEntity, DeriveEntityModel, DeriveIden, DeriveIntoActiveModel, DeriveMigrationName,
612    DeriveModel, DerivePartialModel, DerivePrimaryKey, DeriveRelatedEntity, DeriveRelation,
613    DeriveValueType, FromJsonQueryResult, FromQueryResult, raw_sql,
614};
615
616pub use sea_query;
617pub use sea_query::Iden;
618
619pub use sea_orm_macros::EnumIter;
620pub use strum;
621
622#[cfg(feature = "sqlx-dep")]
623pub use sqlx;