pub trait QueryOrder: Sized {
type QueryStatement: OrderedStatement;
// Required method
fn query(&mut self) -> &mut SelectStatement;
// Provided methods
fn order_by<C>(self, col: C, ord: Order) -> Self
where C: IntoSimpleExpr { ... }
fn order_by_asc<C>(self, col: C) -> Self
where C: IntoSimpleExpr { ... }
fn order_by_desc<C>(self, col: C) -> Self
where C: IntoSimpleExpr { ... }
fn order_by_with_nulls<C>(
self,
col: C,
ord: Order,
nulls: NullOrdering,
) -> Self
where C: IntoSimpleExpr { ... }
}
Expand description
Performs ORDER BY operations
Required Associated Typesยง
Required Methodsยง
Sourcefn query(&mut self) -> &mut SelectStatement
fn query(&mut self) -> &mut SelectStatement
Add the query to perform an ORDER BY operation
Provided Methodsยง
Sourcefn order_by<C>(self, col: C, ord: Order) -> Selfwhere
C: IntoSimpleExpr,
fn order_by<C>(self, col: C, ord: Order) -> Selfwhere
C: IntoSimpleExpr,
Add an order_by expression
use sea_orm::{entity::*, query::*, tests_cfg::cake, DbBackend};
assert_eq!(
cake::Entity::find()
.order_by(cake::Column::Id, Order::Asc)
.order_by(cake::Column::Name, Order::Desc)
.build(DbBackend::MySql)
.to_string(),
"SELECT `cake`.`id`, `cake`.`name` FROM `cake` ORDER BY `cake`.`id` ASC, `cake`.`name` DESC"
);
Sourcefn order_by_asc<C>(self, col: C) -> Selfwhere
C: IntoSimpleExpr,
fn order_by_asc<C>(self, col: C) -> Selfwhere
C: IntoSimpleExpr,
Add an order_by expression (ascending)
use sea_orm::{entity::*, query::*, tests_cfg::cake, DbBackend};
assert_eq!(
cake::Entity::find()
.order_by_asc(cake::Column::Id)
.build(DbBackend::MySql)
.to_string(),
"SELECT `cake`.`id`, `cake`.`name` FROM `cake` ORDER BY `cake`.`id` ASC"
);
Sourcefn order_by_desc<C>(self, col: C) -> Selfwhere
C: IntoSimpleExpr,
fn order_by_desc<C>(self, col: C) -> Selfwhere
C: IntoSimpleExpr,
Add an order_by expression (descending)
use sea_orm::{entity::*, query::*, tests_cfg::cake, DbBackend};
assert_eq!(
cake::Entity::find()
.order_by_desc(cake::Column::Id)
.build(DbBackend::MySql)
.to_string(),
"SELECT `cake`.`id`, `cake`.`name` FROM `cake` ORDER BY `cake`.`id` DESC"
);
Sourcefn order_by_with_nulls<C>(self, col: C, ord: Order, nulls: NullOrdering) -> Selfwhere
C: IntoSimpleExpr,
fn order_by_with_nulls<C>(self, col: C, ord: Order, nulls: NullOrdering) -> Selfwhere
C: IntoSimpleExpr,
Add an order_by expression with nulls ordering option
use sea_orm::{entity::*, query::*, tests_cfg::cake, DbBackend};
use sea_query::NullOrdering;
assert_eq!(
cake::Entity::find()
.order_by_with_nulls(cake::Column::Id, Order::Asc, NullOrdering::First)
.build(DbBackend::Postgres)
.to_string(),
r#"SELECT "cake"."id", "cake"."name" FROM "cake" ORDER BY "cake"."id" ASC NULLS FIRST"#
);
Dyn Compatibilityยง
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.