pub trait TryGetableMany: Sized {
    fn try_get_many(
        res: &QueryResult,
        pre: &str,
        cols: &[String]
    ) -> Result<Self, TryGetError>; fn try_get_many_by_index(res: &QueryResult) -> Result<Self, TryGetError>; fn find_by_statement<C>(
        stmt: Statement
    ) -> SelectorRaw<SelectGetableValue<Self, C>>
    where
        C: IntoEnumIterator + Iden
, { ... } }
Expand description

An interface to get a tuple value from the query result

Required Methods§

source

fn try_get_many(
    res: &QueryResult,
    pre: &str,
    cols: &[String]
) -> Result<Self, TryGetError>

Get a tuple value from the query result with prefixed column name

source

fn try_get_many_by_index(res: &QueryResult) -> Result<Self, TryGetError>

Get a tuple value from the query result based on the order in the select expressions

Provided Methods§

source

fn find_by_statement<C>(
    stmt: Statement
) -> SelectorRaw<SelectGetableValue<Self, C>>where
    C: IntoEnumIterator + Iden,

use sea_orm::{entity::*, query::*, tests_cfg::cake, DeriveIden, EnumIter, TryGetableMany};

#[derive(EnumIter, DeriveIden)]
enum ResultCol {
    Name,
    NumOfCakes,
}

let res: Vec<(String, i32)> =
    <(String, i32)>::find_by_statement::<ResultCol>(Statement::from_sql_and_values(
        DbBackend::Postgres,
        r#"SELECT "cake"."name", count("cake"."id") AS "num_of_cakes" FROM "cake""#,
        [],
    ))
    .all(&db)
    .await?;

assert_eq!(
    res,
    [
        ("Chocolate Forest".to_owned(), 1),
        ("New York Cheese".to_owned(), 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""#,
        []
    ),]
);

Implementations on Foreign Types§

source§

impl<T> TryGetableMany for (T,)where
    T: TryGetableMany,

source§

fn try_get_many(
    res: &QueryResult,
    pre: &str,
    cols: &[String]
) -> Result<Self, TryGetError>

source§

fn try_get_many_by_index(res: &QueryResult) -> Result<Self, TryGetError>

source§

impl<A, B> TryGetableMany for (A, B)where
    A: TryGetable,
    B: TryGetable,

source§

fn try_get_many(
    res: &QueryResult,
    pre: &str,
    cols: &[String]
) -> Result<Self, TryGetError>

source§

fn try_get_many_by_index(res: &QueryResult) -> Result<Self, TryGetError>

source§

impl<A, B, C> TryGetableMany for (A, B, C)where
    A: TryGetable,
    B: TryGetable,
    C: TryGetable,

source§

fn try_get_many(
    res: &QueryResult,
    pre: &str,
    cols: &[String]
) -> Result<Self, TryGetError>

source§

fn try_get_many_by_index(res: &QueryResult) -> Result<Self, TryGetError>

source§

impl<A, B, C, D> TryGetableMany for (A, B, C, D)where
    A: TryGetable,
    B: TryGetable,
    C: TryGetable,
    D: TryGetable,

source§

fn try_get_many(
    res: &QueryResult,
    pre: &str,
    cols: &[String]
) -> Result<Self, TryGetError>

source§

fn try_get_many_by_index(res: &QueryResult) -> Result<Self, TryGetError>

source§

impl<A, B, C, D, E> TryGetableMany for (A, B, C, D, E)where
    A: TryGetable,
    B: TryGetable,
    C: TryGetable,
    D: TryGetable,
    E: TryGetable,

source§

fn try_get_many(
    res: &QueryResult,
    pre: &str,
    cols: &[String]
) -> Result<Self, TryGetError>

source§

fn try_get_many_by_index(res: &QueryResult) -> Result<Self, TryGetError>

source§

impl<A, B, C, D, E, F> TryGetableMany for (A, B, C, D, E, F)where
    A: TryGetable,
    B: TryGetable,
    C: TryGetable,
    D: TryGetable,
    E: TryGetable,
    F: TryGetable,

source§

fn try_get_many(
    res: &QueryResult,
    pre: &str,
    cols: &[String]
) -> Result<Self, TryGetError>

source§

fn try_get_many_by_index(res: &QueryResult) -> Result<Self, TryGetError>

Implementors§

source§

impl<T> TryGetableMany for Twhere
    T: TryGetable,