Struct Select

Source
pub struct Select<DB>
where DB: Database,
{ pub table_name: TableName, pub table_field: TableFields, pub table_pk: TableFields, /* private fields */ }
Expand description

查询操作

Fields§

§table_name: TableName§table_field: TableFields§table_pk: TableFields

Implementations§

Source§

impl<DB> Select<DB>
where DB: Database,

Source

pub fn new( table_name: TableName, table_field: TableFields, table_pk: TableFields, ) -> Self

Source

pub fn type_new<T>() -> Self

Source

pub async fn fetch_one_by_scalar_pk<'c, M, PT, E>( &self, pk_scalar: PT, executor: E, ) -> Result<M, Error>
where for<'q> PT: 'q + Send + Encode<'q, DB> + Type<DB>, for<'r> M: FromRow<'r, DB::Row> + Send + Unpin + ModelTableField<DB>, for<'n> <DB as HasArguments<'n>>::Arguments: Arguments<'n> + IntoArguments<'n, DB>, E: Executor<'c, Database = DB>,

非联合主键的表通过主键值查找某记录 @field_name 需要获取的字段名 @pk_scalar 主键值 @executor Executor M 为 Model 类型

Source

pub async fn fetch_one_scalar_by_scalar_pk<'c, M, PT, E>( &self, field_name: &str, pk_scalar: PT, executor: E, ) -> Result<M, Error>
where for<'q> PT: 'q + Send + Encode<'q, DB> + Type<DB>, (M,): for<'r> FromRow<'r, DB::Row> + Send + Unpin, M: Send + Unpin, for<'n> <DB as HasArguments<'n>>::Arguments: Arguments<'n> + IntoArguments<'n, DB>, E: Executor<'c, Database = DB>,

非联合主键的表通过主键值查找某字段值 @field_name 需要获取的字段名 @pk_scalar 主键值 @executor Executor M 为 @field_name 字段类型

Source

pub async fn reload<'c, M, E>(&self, val: &M, executor: E) -> Result<M, Error>
where M: for<'r> FromRow<'r, DB::Row> + Send + Unpin + ModelTableField<DB>, for<'n> <DB as HasArguments<'n>>::Arguments: Arguments<'n> + IntoArguments<'n, DB>, E: Executor<'c, Database = DB>,

从DB中重新加载Model里值 @val Model 变量 @executor Executor

Source§

impl Select<MySql>

Source

pub async fn fetch_all_by_where<'c, M, E>( &self, where_sql: &WhereOption, executor: E, ) -> Result<Vec<M>, Error>
where for<'r> M: FromRow<'r, <MySql as Database>::Row> + Send + Unpin + ModelTableField<MySql>, for<'n> <MySql as HasArguments<'n>>::Arguments: Arguments<'n> + IntoArguments<'n, MySql>, E: Executor<'c, Database = MySql>,

M 为 Model 类型

Source§

impl Select<MySql>

Source

pub async fn fetch_one_by_where<'c, M, E>( &self, where_sql: &WhereOption, executor: E, ) -> Result<M, Error>
where for<'r> M: FromRow<'r, <MySql as Database>::Row> + Send + Unpin + ModelTableField<MySql>, for<'n> <MySql as HasArguments<'n>>::Arguments: Arguments<'n> + IntoArguments<'n, MySql>, E: Executor<'c, Database = MySql>,

M 为 Model 类型

Source§

impl Select<Sqlite>

Source

pub async fn fetch_all_by_where<'c, M, E>( &self, where_sql: &WhereOption, executor: E, ) -> Result<Vec<M>, Error>
where for<'r> M: FromRow<'r, <Sqlite as Database>::Row> + Send + Unpin + ModelTableField<Sqlite>, for<'n> <Sqlite as HasArguments<'n>>::Arguments: Arguments<'n> + IntoArguments<'n, Sqlite>, E: Executor<'c, Database = Sqlite>,

M 为 Model 类型

Source§

impl Select<Sqlite>

Source

pub async fn fetch_one_by_where<'c, M, E>( &self, where_sql: &WhereOption, executor: E, ) -> Result<M, Error>
where for<'r> M: FromRow<'r, <Sqlite as Database>::Row> + Send + Unpin + ModelTableField<Sqlite>, for<'n> <Sqlite as HasArguments<'n>>::Arguments: Arguments<'n> + IntoArguments<'n, Sqlite>, E: Executor<'c, Database = Sqlite>,

M 为 Model 类型

Source§

impl Select<Postgres>

Source

pub async fn fetch_all_by_where<'c, M, E>( &self, where_sql: &WhereOption, executor: E, ) -> Result<Vec<M>, Error>
where for<'r> M: FromRow<'r, <Postgres as Database>::Row> + Send + Unpin + ModelTableField<Postgres>, for<'n> <Postgres as HasArguments<'n>>::Arguments: Arguments<'n> + IntoArguments<'n, Postgres>, E: Executor<'c, Database = Postgres>,

M 为 Model 类型

Source§

impl Select<Postgres>

Source

pub async fn fetch_one_by_where<'c, M, E>( &self, where_sql: &WhereOption, executor: E, ) -> Result<M, Error>
where for<'r> M: FromRow<'r, <Postgres as Database>::Row> + Send + Unpin + ModelTableField<Postgres>, for<'n> <Postgres as HasArguments<'n>>::Arguments: Arguments<'n> + IntoArguments<'n, Postgres>, E: Executor<'c, Database = Postgres>,

M 为 Model 类型

Source§

impl Select<Mssql>

Source

pub async fn fetch_all_by_where<'c, M, E>( &self, where_sql: &WhereOption, executor: E, ) -> Result<Vec<M>, Error>
where for<'r> M: FromRow<'r, <Mssql as Database>::Row> + Send + Unpin + ModelTableField<Mssql>, for<'n> <Mssql as HasArguments<'n>>::Arguments: Arguments<'n> + IntoArguments<'n, Mssql>, E: Executor<'c, Database = Mssql>,

M 为 Model 类型

Source§

impl Select<Mssql>

Source

pub async fn fetch_one_by_where<'c, M, E>( &self, where_sql: &WhereOption, executor: E, ) -> Result<M, Error>
where for<'r> M: FromRow<'r, <Mssql as Database>::Row> + Send + Unpin + ModelTableField<Mssql>, for<'n> <Mssql as HasArguments<'n>>::Arguments: Arguments<'n> + IntoArguments<'n, Mssql>, E: Executor<'c, Database = Mssql>,

M 为 Model 类型

Source§

impl Select<MySql>

Source

pub async fn fetch_all_scalar_by_where<'c, M, E>( &self, field_name: &str, where_sql: &WhereOption, executor: E, ) -> Result<Vec<M>, Error>
where (M,): for<'r> FromRow<'r, <MySql as Database>::Row> + Send + Unpin, M: Send + Unpin, for<'n> <MySql as HasArguments<'n>>::Arguments: Arguments<'n> + IntoArguments<'n, MySql>, E: Executor<'c, Database = MySql>,

M 为 返回某字段类型

Source§

impl Select<MySql>

Source

pub async fn fetch_one_scalar_by_where<'c, M, E>( &self, field_name: &str, where_sql: &WhereOption, executor: E, ) -> Result<M, Error>
where (M,): for<'r> FromRow<'r, <MySql as Database>::Row> + Send + Unpin, M: Send + Unpin, for<'n> <MySql as HasArguments<'n>>::Arguments: Arguments<'n> + IntoArguments<'n, MySql>, E: Executor<'c, Database = MySql>,

M 为 返回某字段类型

Source§

impl Select<Sqlite>

Source

pub async fn fetch_all_scalar_by_where<'c, M, E>( &self, field_name: &str, where_sql: &WhereOption, executor: E, ) -> Result<Vec<M>, Error>
where (M,): for<'r> FromRow<'r, <Sqlite as Database>::Row> + Send + Unpin, M: Send + Unpin, for<'n> <Sqlite as HasArguments<'n>>::Arguments: Arguments<'n> + IntoArguments<'n, Sqlite>, E: Executor<'c, Database = Sqlite>,

M 为 返回某字段类型

Source§

impl Select<Sqlite>

Source

pub async fn fetch_one_scalar_by_where<'c, M, E>( &self, field_name: &str, where_sql: &WhereOption, executor: E, ) -> Result<M, Error>
where (M,): for<'r> FromRow<'r, <Sqlite as Database>::Row> + Send + Unpin, M: Send + Unpin, for<'n> <Sqlite as HasArguments<'n>>::Arguments: Arguments<'n> + IntoArguments<'n, Sqlite>, E: Executor<'c, Database = Sqlite>,

M 为 返回某字段类型

Source§

impl Select<Postgres>

Source

pub async fn fetch_all_scalar_by_where<'c, M, E>( &self, field_name: &str, where_sql: &WhereOption, executor: E, ) -> Result<Vec<M>, Error>
where (M,): for<'r> FromRow<'r, <Postgres as Database>::Row> + Send + Unpin, M: Send + Unpin, for<'n> <Postgres as HasArguments<'n>>::Arguments: Arguments<'n> + IntoArguments<'n, Postgres>, E: Executor<'c, Database = Postgres>,

M 为 返回某字段类型

Source§

impl Select<Postgres>

Source

pub async fn fetch_one_scalar_by_where<'c, M, E>( &self, field_name: &str, where_sql: &WhereOption, executor: E, ) -> Result<M, Error>
where (M,): for<'r> FromRow<'r, <Postgres as Database>::Row> + Send + Unpin, M: Send + Unpin, for<'n> <Postgres as HasArguments<'n>>::Arguments: Arguments<'n> + IntoArguments<'n, Postgres>, E: Executor<'c, Database = Postgres>,

M 为 返回某字段类型

Source§

impl Select<Mssql>

Source

pub async fn fetch_all_scalar_by_where<'c, M, E>( &self, field_name: &str, where_sql: &WhereOption, executor: E, ) -> Result<Vec<M>, Error>
where (M,): for<'r> FromRow<'r, <Mssql as Database>::Row> + Send + Unpin, M: Send + Unpin, for<'n> <Mssql as HasArguments<'n>>::Arguments: Arguments<'n> + IntoArguments<'n, Mssql>, E: Executor<'c, Database = Mssql>,

M 为 返回某字段类型

Source§

impl Select<Mssql>

Source

pub async fn fetch_one_scalar_by_where<'c, M, E>( &self, field_name: &str, where_sql: &WhereOption, executor: E, ) -> Result<M, Error>
where (M,): for<'r> FromRow<'r, <Mssql as Database>::Row> + Send + Unpin, M: Send + Unpin, for<'n> <Mssql as HasArguments<'n>>::Arguments: Arguments<'n> + IntoArguments<'n, Mssql>, E: Executor<'c, Database = Mssql>,

M 为 返回某字段类型

Auto Trait Implementations§

§

impl<DB> Freeze for Select<DB>

§

impl<DB> RefUnwindSafe for Select<DB>
where DB: RefUnwindSafe,

§

impl<DB> Send for Select<DB>

§

impl<DB> Sync for Select<DB>
where DB: Sync,

§

impl<DB> Unpin for Select<DB>
where DB: Unpin,

§

impl<DB> UnwindSafe for Select<DB>
where DB: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T