Trait sea_orm::query::QuerySelect [−][src]
pub trait QuerySelect: Sized { type QueryStatement; fn query(&mut self) -> &mut SelectStatement; fn select_only(self) -> Self { ... } fn column<C>(self, col: C) -> Self
where
C: ColumnTrait, { ... } fn column_as<C>(self, col: C, alias: &str) -> Self
where
C: IntoSimpleExpr, { ... } fn group_by<C>(self, col: C) -> Self
where
C: IntoSimpleExpr, { ... } fn having<F>(self, filter: F) -> Self
where
F: IntoCondition, { ... } fn join(self, join: JoinType, rel: RelationDef) -> Self { ... } fn join_rev(self, join: JoinType, rel: RelationDef) -> Self { ... } }
Associated Types
type QueryStatement
Required methods
fn query(&mut self) -> &mut SelectStatement
Provided methods
fn select_only(self) -> Self
fn select_only(self) -> Self
Clear the selection list
fn column<C>(self, col: C) -> Self where
C: ColumnTrait,
fn column<C>(self, col: C) -> Self where
C: ColumnTrait,
Add a select column
use sea_orm::{entity::*, query::*, tests_cfg::cake, DbBackend}; assert_eq!( cake::Entity::find() .select_only() .column(cake::Column::Name) .build(DbBackend::Postgres) .to_string(), r#"SELECT "cake"."name" FROM "cake""# );
fn column_as<C>(self, col: C, alias: &str) -> Self where
C: IntoSimpleExpr,
fn column_as<C>(self, col: C, alias: &str) -> Self where
C: IntoSimpleExpr,
Add a select column with alias
use sea_orm::{entity::*, query::*, tests_cfg::cake, DbBackend}; assert_eq!( cake::Entity::find() .select_only() .column_as(cake::Column::Id.count(), "count") .build(DbBackend::Postgres) .to_string(), r#"SELECT COUNT("cake"."id") AS "count" FROM "cake""# );
fn group_by<C>(self, col: C) -> Self where
C: IntoSimpleExpr,
fn group_by<C>(self, col: C) -> Self where
C: IntoSimpleExpr,
Add a group by column
use sea_orm::{entity::*, query::*, tests_cfg::cake, DbBackend}; assert_eq!( cake::Entity::find() .select_only() .column(cake::Column::Name) .group_by(cake::Column::Name) .build(DbBackend::Postgres) .to_string(), r#"SELECT "cake"."name" FROM "cake" GROUP BY "cake"."name""# );
fn having<F>(self, filter: F) -> Self where
F: IntoCondition,
fn having<F>(self, filter: F) -> Self where
F: IntoCondition,
Add an AND HAVING expression
use sea_orm::{entity::*, query::*, tests_cfg::cake, DbBackend}; assert_eq!( cake::Entity::find() .having(cake::Column::Id.eq(4)) .having(cake::Column::Id.eq(5)) .build(DbBackend::MySql) .to_string(), "SELECT `cake`.`id`, `cake`.`name` FROM `cake` HAVING `cake`.`id` = 4 AND `cake`.`id` = 5" );
fn join(self, join: JoinType, rel: RelationDef) -> Self
fn join(self, join: JoinType, rel: RelationDef) -> Self
Join via RelationDef
.
fn join_rev(self, join: JoinType, rel: RelationDef) -> Self
fn join_rev(self, join: JoinType, rel: RelationDef) -> Self
Join via RelationDef
but in reverse direction.
Assume when there exist a relation A to B.
You can reverse join B from A.