Struct SelectorRaw  
pub struct SelectorRaw<S>where
    S: SelectorTrait,{
    pub(crate) stmt: Statement,
    selector: S,
}Expand description
Performs a raw SELECT operation on a model
Fields§
§stmt: Statement§selector: SImplementations§
§impl<S> SelectorRaw<S>where
    S: SelectorTrait,
 
impl<S> SelectorRaw<S>where
    S: SelectorTrait,
pub fn from_statement<M>(stmt: Statement) -> SelectorRaw<SelectModel<M>>where
    M: FromQueryResult,
pub fn from_statement<M>(stmt: Statement) -> SelectorRaw<SelectModel<M>>where
    M: FromQueryResult,
Select a custom Model from a raw SQL Statement.
pub fn with_columns<T, C>(
    stmt: Statement,
) -> SelectorRaw<SelectGetableValue<T, C>>
pub fn with_columns<T, C>( stmt: Statement, ) -> SelectorRaw<SelectGetableValue<T, C>>
Create SelectorRaw from Statement and columns. Executing this SelectorRaw will
return a type T which implement TryGetableMany.
pub fn into_model<M>(self) -> SelectorRaw<SelectModel<M>>where
    M: FromQueryResult,
pub fn into_model<M>(self) -> SelectorRaw<SelectModel<M>>where
    M: FromQueryResult,
use sea_orm::{entity::*, query::*, tests_cfg::cake, FromQueryResult};
#[derive(Debug, PartialEq, FromQueryResult)]
struct SelectResult {
    name: String,
    num_of_cakes: i32,
}
let res: Vec<SelectResult> = cake::Entity::find()
    .from_raw_sql(Statement::from_sql_and_values(
        DbBackend::Postgres,
        r#"SELECT "cake"."name", count("cake"."id") AS "num_of_cakes" FROM "cake""#,
        [],
    ))
    .into_model::<SelectResult>()
    .all(&db)
    .await?;
assert_eq!(
    res,
    [
        SelectResult {
            name: "Chocolate Forest".to_owned(),
            num_of_cakes: 1,
        },
        SelectResult {
            name: "New York Cheese".to_owned(),
            num_of_cakes: 1,
        },
    ]
);
assert_eq!(
    db.into_transaction_log(),
    [Transaction::from_sql_and_values(
        DbBackend::Postgres,
        r#"SELECT "cake"."name", count("cake"."id") AS "num_of_cakes" FROM "cake""#,
        []
    ),]
);pub fn into_json(self) -> SelectorRaw<SelectModel<Value>>
pub fn into_json(self) -> SelectorRaw<SelectModel<Value>>
use sea_orm::{entity::*, query::*, tests_cfg::cake};
let res: Vec<serde_json::Value> = cake::Entity::find().from_raw_sql(
    Statement::from_sql_and_values(
        DbBackend::Postgres, r#"SELECT "cake"."id", "cake"."name" FROM "cake""#, []
    )
)
.into_json()
.all(&db)
.await?;
assert_eq!(
    res,
    [
        serde_json::json!({
            "name": "Chocolate Forest",
            "num_of_cakes": 1,
        }),
        serde_json::json!({
            "name": "New York Cheese",
            "num_of_cakes": 1,
        }),
    ]
);
assert_eq!(
    db.into_transaction_log(),
    [
    Transaction::from_sql_and_values(
            DbBackend::Postgres, r#"SELECT "cake"."id", "cake"."name" FROM "cake""#, []
    ),
]);pub fn into_statement(self) -> Statement
pub fn into_statement(self) -> Statement
Get the SQL statement
pub async fn one<'a, C>(
    self,
    db: &C,
) -> Result<Option<<S as SelectorTrait>::Item>, DbErr>where
    C: ConnectionTrait,
pub async fn one<'a, C>(
    self,
    db: &C,
) -> Result<Option<<S as SelectorTrait>::Item>, DbErr>where
    C: ConnectionTrait,
Get an item from the Select query
use sea_orm::{entity::*, query::*, tests_cfg::cake};
let _: Option<cake::Model> = cake::Entity::find()
    .from_raw_sql(Statement::from_sql_and_values(
        DbBackend::Postgres,
        r#"SELECT "cake"."id", "cake"."name" FROM "cake" WHERE "id" = $1"#,
        [1.into()],
    ))
    .one(&db)
    .await?;
assert_eq!(
    db.into_transaction_log(),
    [Transaction::from_sql_and_values(
        DbBackend::Postgres,
        r#"SELECT "cake"."id", "cake"."name" FROM "cake" WHERE "id" = $1"#,
        [1.into()]
    ),]
);pub async fn all<'a, C>(
    self,
    db: &C,
) -> Result<Vec<<S as SelectorTrait>::Item>, DbErr>where
    C: ConnectionTrait,
pub async fn all<'a, C>(
    self,
    db: &C,
) -> Result<Vec<<S as SelectorTrait>::Item>, DbErr>where
    C: ConnectionTrait,
Get all items from the Select query
use sea_orm::{entity::*, query::*, tests_cfg::cake};
let _: Vec<cake::Model> = cake::Entity::find()
    .from_raw_sql(Statement::from_sql_and_values(
        DbBackend::Postgres,
        r#"SELECT "cake"."id", "cake"."name" FROM "cake""#,
        [],
    ))
    .all(&db)
    .await?;
assert_eq!(
    db.into_transaction_log(),
    [Transaction::from_sql_and_values(
        DbBackend::Postgres,
        r#"SELECT "cake"."id", "cake"."name" FROM "cake""#,
        []
    ),]
);Trait Implementations§
§impl<S> Clone for SelectorRaw<S>where
    S: Clone + SelectorTrait,
 
impl<S> Clone for SelectorRaw<S>where
    S: Clone + SelectorTrait,
§fn clone(&self) -> SelectorRaw<S>
 
fn clone(&self) -> SelectorRaw<S>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
 
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from 
source. Read more§impl<S> Debug for SelectorRaw<S>where
    S: Debug + SelectorTrait,
 
impl<S> Debug for SelectorRaw<S>where
    S: Debug + SelectorTrait,
§impl<'db, C, S> PaginatorTrait<'db, C> for SelectorRaw<S>
 
impl<'db, C, S> PaginatorTrait<'db, C> for SelectorRaw<S>
Auto Trait Implementations§
impl<S> Freeze for SelectorRaw<S>where
    S: Freeze,
impl<S> RefUnwindSafe for SelectorRaw<S>where
    S: RefUnwindSafe,
impl<S> Send for SelectorRaw<S>where
    S: Send,
impl<S> Sync for SelectorRaw<S>where
    S: Sync,
impl<S> Unpin for SelectorRaw<S>where
    S: Unpin,
impl<S> UnwindSafe for SelectorRaw<S>where
    S: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
    T: ?Sized,
 
impl<T> BorrowMut<T> for Twhere
    T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
 
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
    T: Clone,
 
impl<T> CloneToUninit for Twhere
    T: Clone,
§impl<T> Instrument for T
 
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
 
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
 
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
 
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
 
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts 
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
 
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts 
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more