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,
impl<DB> Select<DB>where
DB: Database,
pub fn new( table_name: TableName, table_field: TableFields, table_pk: TableFields, ) -> Self
pub fn type_new<T>() -> Selfwhere
T: ModelTableField<DB> + ModelTableName,
Sourcepub 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>,
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 类型
Sourcepub async fn fetch_one_scalar_by_scalar_pk<'c, M, PT, E>(
&self,
field_name: &str,
pk_scalar: PT,
executor: E,
) -> Result<M, Error>
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>
非联合主键的表通过主键值查找某字段值 @field_name 需要获取的字段名 @pk_scalar 主键值 @executor Executor M 为 @field_name 字段类型
Sourcepub 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>,
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>
impl Select<MySql>
Sourcepub async fn fetch_all_by_where<'c, M, E>(
&self,
where_sql: &WhereOption,
executor: E,
) -> Result<Vec<M>, Error>
pub async fn fetch_all_by_where<'c, M, E>( &self, where_sql: &WhereOption, executor: E, ) -> Result<Vec<M>, Error>
M 为 Model 类型
Source§impl Select<MySql>
impl Select<MySql>
Sourcepub async fn fetch_one_by_where<'c, M, E>(
&self,
where_sql: &WhereOption,
executor: E,
) -> Result<M, Error>
pub async fn fetch_one_by_where<'c, M, E>( &self, where_sql: &WhereOption, executor: E, ) -> Result<M, Error>
M 为 Model 类型
Source§impl Select<Sqlite>
impl Select<Sqlite>
Sourcepub async fn fetch_all_by_where<'c, M, E>(
&self,
where_sql: &WhereOption,
executor: E,
) -> Result<Vec<M>, Error>
pub async fn fetch_all_by_where<'c, M, E>( &self, where_sql: &WhereOption, executor: E, ) -> Result<Vec<M>, Error>
M 为 Model 类型
Source§impl Select<Sqlite>
impl Select<Sqlite>
Sourcepub async fn fetch_one_by_where<'c, M, E>(
&self,
where_sql: &WhereOption,
executor: E,
) -> Result<M, Error>
pub async fn fetch_one_by_where<'c, M, E>( &self, where_sql: &WhereOption, executor: E, ) -> Result<M, Error>
M 为 Model 类型
Source§impl Select<Postgres>
impl Select<Postgres>
Sourcepub async fn fetch_all_by_where<'c, M, E>(
&self,
where_sql: &WhereOption,
executor: E,
) -> Result<Vec<M>, Error>
pub async fn fetch_all_by_where<'c, M, E>( &self, where_sql: &WhereOption, executor: E, ) -> Result<Vec<M>, Error>
M 为 Model 类型
Source§impl Select<Postgres>
impl Select<Postgres>
Sourcepub async fn fetch_one_by_where<'c, M, E>(
&self,
where_sql: &WhereOption,
executor: E,
) -> Result<M, Error>
pub async fn fetch_one_by_where<'c, M, E>( &self, where_sql: &WhereOption, executor: E, ) -> Result<M, Error>
M 为 Model 类型
Source§impl Select<Mssql>
impl Select<Mssql>
Sourcepub async fn fetch_all_by_where<'c, M, E>(
&self,
where_sql: &WhereOption,
executor: E,
) -> Result<Vec<M>, Error>
pub async fn fetch_all_by_where<'c, M, E>( &self, where_sql: &WhereOption, executor: E, ) -> Result<Vec<M>, Error>
M 为 Model 类型
Source§impl Select<Mssql>
impl Select<Mssql>
Sourcepub async fn fetch_one_by_where<'c, M, E>(
&self,
where_sql: &WhereOption,
executor: E,
) -> Result<M, Error>
pub async fn fetch_one_by_where<'c, M, E>( &self, where_sql: &WhereOption, executor: E, ) -> Result<M, Error>
M 为 Model 类型
Source§impl Select<MySql>
impl Select<MySql>
Sourcepub async fn fetch_all_scalar_by_where<'c, M, E>(
&self,
field_name: &str,
where_sql: &WhereOption,
executor: E,
) -> Result<Vec<M>, Error>
pub async fn fetch_all_scalar_by_where<'c, M, E>( &self, field_name: &str, where_sql: &WhereOption, executor: E, ) -> Result<Vec<M>, Error>
M 为 返回某字段类型
Source§impl Select<MySql>
impl Select<MySql>
Sourcepub async fn fetch_one_scalar_by_where<'c, M, E>(
&self,
field_name: &str,
where_sql: &WhereOption,
executor: E,
) -> Result<M, Error>
pub async fn fetch_one_scalar_by_where<'c, M, E>( &self, field_name: &str, where_sql: &WhereOption, executor: E, ) -> Result<M, Error>
M 为 返回某字段类型
Source§impl Select<Sqlite>
impl Select<Sqlite>
Sourcepub async fn fetch_all_scalar_by_where<'c, M, E>(
&self,
field_name: &str,
where_sql: &WhereOption,
executor: E,
) -> Result<Vec<M>, Error>
pub async fn fetch_all_scalar_by_where<'c, M, E>( &self, field_name: &str, where_sql: &WhereOption, executor: E, ) -> Result<Vec<M>, Error>
M 为 返回某字段类型
Source§impl Select<Sqlite>
impl Select<Sqlite>
Sourcepub async fn fetch_one_scalar_by_where<'c, M, E>(
&self,
field_name: &str,
where_sql: &WhereOption,
executor: E,
) -> Result<M, Error>
pub async fn fetch_one_scalar_by_where<'c, M, E>( &self, field_name: &str, where_sql: &WhereOption, executor: E, ) -> Result<M, Error>
M 为 返回某字段类型
Source§impl Select<Postgres>
impl Select<Postgres>
Sourcepub async fn fetch_all_scalar_by_where<'c, M, E>(
&self,
field_name: &str,
where_sql: &WhereOption,
executor: E,
) -> Result<Vec<M>, Error>
pub async fn fetch_all_scalar_by_where<'c, M, E>( &self, field_name: &str, where_sql: &WhereOption, executor: E, ) -> Result<Vec<M>, Error>
M 为 返回某字段类型
Source§impl Select<Postgres>
impl Select<Postgres>
Sourcepub async fn fetch_one_scalar_by_where<'c, M, E>(
&self,
field_name: &str,
where_sql: &WhereOption,
executor: E,
) -> Result<M, Error>
pub async fn fetch_one_scalar_by_where<'c, M, E>( &self, field_name: &str, where_sql: &WhereOption, executor: E, ) -> Result<M, Error>
M 为 返回某字段类型
Source§impl Select<Mssql>
impl Select<Mssql>
Sourcepub async fn fetch_all_scalar_by_where<'c, M, E>(
&self,
field_name: &str,
where_sql: &WhereOption,
executor: E,
) -> Result<Vec<M>, Error>
pub async fn fetch_all_scalar_by_where<'c, M, E>( &self, field_name: &str, where_sql: &WhereOption, executor: E, ) -> Result<Vec<M>, Error>
M 为 返回某字段类型
Source§impl Select<Mssql>
impl Select<Mssql>
Sourcepub async fn fetch_one_scalar_by_where<'c, M, E>(
&self,
field_name: &str,
where_sql: &WhereOption,
executor: E,
) -> Result<M, Error>
pub async fn fetch_one_scalar_by_where<'c, M, E>( &self, field_name: &str, where_sql: &WhereOption, executor: E, ) -> Result<M, Error>
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> 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> 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