diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md index 674b3163..09cd26a2 100644 --- a/ARCHITECTURE.md +++ b/ARCHITECTURE.md @@ -1,5 +1,7 @@ # Architecture +> Let's dive under the Sea 🤿 + To understand the architecture of SeaORM, let's discuss what is an ORM. ORM exists to provide abstractions over common operations you would do against a database and hide the implementation details like the actual SQL queries. With a good ORM, you shouldn't bother to look under the API surface. Until you do. I hear you say *'abstraction leaks'*, and yes, it does. diff --git a/README.md b/README.md index 1c0e83d1..2285c77c 100644 --- a/README.md +++ b/README.md @@ -239,7 +239,7 @@ fruit::Entity::delete_many() 1. [Design](https://github.com/SeaQL/sea-orm/tree/master/DESIGN.md) 1. [Architecture](https://github.com/SeaQL/sea-orm/tree/master/ARCHITECTURE.md) -1. [Compare with Diesel](https://www.sea-ql.org/SeaORM/docs/internal-design/diesel) +1. [Change Log](https://github.com/SeaQL/sea-orm/tree/master/CHANGELOG.md) ## License diff --git a/src/lib.rs b/src/lib.rs index 7ffbbf9b..a1dc83f7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -335,7 +335,7 @@ //! //! 1. [Design](https://github.com/SeaQL/sea-orm/tree/master/DESIGN.md) //! 1. [Architecture](https://github.com/SeaQL/sea-orm/tree/master/ARCHITECTURE.md) -//! 1. [Compare with Diesel](https://www.sea-ql.org/SeaORM/docs/internal-design/diesel) +//! 1. [Change Log](https://github.com/SeaQL/sea-orm/tree/master/CHANGELOG.md) //! //! ## License //! diff --git a/src/query/helper.rs b/src/query/helper.rs index e6df3637..43fed28a 100644 --- a/src/query/helper.rs +++ b/src/query/helper.rs @@ -269,6 +269,48 @@ pub trait QueryFilter: Sized { /// "SELECT `cake`.`id`, `cake`.`name` FROM `cake` WHERE `cake`.`id` = 4 OR `cake`.`id` = 5" /// ); /// ``` + /// + /// Add a runtime-built condition tree. + /// ``` + /// use sea_orm::{entity::*, query::*, tests_cfg::cake, DbBackend}; + /// struct Input { + /// name: Option, + /// } + /// let input = Input { name: Some("cheese".to_owned()) }; + /// + /// let mut conditions = Condition::all(); + /// if let Some(name) = input.name { + /// conditions = conditions.add(cake::Column::Name.contains(&name)); + /// } + /// + /// assert_eq!( + /// cake::Entity::find() + /// .filter(conditions) + /// .build(DbBackend::MySql) + /// .to_string(), + /// "SELECT `cake`.`id`, `cake`.`name` FROM `cake` WHERE `cake`.`name` LIKE '%cheese%'" + /// ); + /// ``` + /// + /// Add a runtime-built condition tree, functional-way. + /// ``` + /// use sea_orm::{entity::*, query::*, tests_cfg::cake, DbBackend}; + /// struct Input { + /// name: Option, + /// } + /// let input = Input { name: Some("cheese".to_owned()) }; + /// + /// assert_eq!( + /// cake::Entity::find() + /// .filter( + /// Condition::all() + /// .add_option(input.name.map(|n| cake::Column::Name.contains(&n))) + /// ) + /// .build(DbBackend::MySql) + /// .to_string(), + /// "SELECT `cake`.`id`, `cake`.`name` FROM `cake` WHERE `cake`.`name` LIKE '%cheese%'" + /// ); + /// ``` fn filter(mut self, filter: F) -> Self where F: IntoCondition,