pub trait QueryBuilder<'a> {
type DB: Database;
// Required methods
fn one<'e, 'c: 'e, E, O>(
&self,
executor: E,
) -> impl Future<Output = Result<O, Error>>
where E: 'e + Executor<'c, Database = Self::DB>,
for<'r> O: 'e + FromRow<'r, <Self::DB as Database>::Row> + Send + Unpin;
fn optional<'e, 'c: 'e, E, O>(
&self,
executor: E,
) -> impl Future<Output = Result<Option<O>, Error>>
where E: 'e + Executor<'c, Database = Self::DB>,
for<'r> O: FromRow<'r, <Self::DB as Database>::Row> + 'e + Send + Unpin;
fn all<'e, 'c: 'e, E, O>(
&self,
executor: E,
) -> impl Future<Output = Result<Vec<O>, Error>>
where E: 'e + Executor<'c, Database = Self::DB>,
for<'r> O: FromRow<'r, <Self::DB as Database>::Row> + 'e + Send + Unpin;
fn map_all<'e, 'c: 'e, E, O, F, K>(
&self,
executor: E,
key_fn: F,
) -> impl Future<Output = Result<HashMap<K, O>, Error>>
where E: 'e + Executor<'c, Database = Self::DB>,
for<'r> O: FromRow<'r, <Self::DB as Database>::Row> + 'e + Send + Unpin,
F: Fn(&O) -> K,
K: Eq + Hash;
fn page<'e, 'c: 'e, E, O>(
&self,
executor: E,
page: &PageRequest,
) -> impl Future<Output = Result<PageResult<O>, Error>>
where E: 'e + Executor<'c, Database = Self::DB>,
for<'r> O: FromRow<'r, <Self::DB as Database>::Row> + 'e + Send + Unpin;
fn count<'c, E>(
&self,
executor: E,
) -> impl Future<Output = Result<usize, Error>>
where E: 'c + Executor<'c, Database = Self::DB>;
fn one_scalar<'q, 'c, E, O>(
&self,
executor: E,
field: &'q Column,
) -> impl Future<Output = Result<O, Error>>
where (O,): for<'r> FromRow<'r, <Self::DB as Database>::Row>,
E: 'c + Executor<'c, Database = Self::DB>,
O: Send + Unpin;
fn optional_scalar<'q, 'c, E, O>(
&self,
executor: E,
field: &'q Column,
) -> impl Future<Output = Result<Option<O>, Error>>
where (O,): for<'r> FromRow<'r, <Self::DB as Database>::Row>,
E: 'c + Executor<'c, Database = Self::DB>,
O: Send + Unpin;
fn all_scalars<'q, 'c, E, O>(
&self,
executor: E,
field: &'q Column,
) -> impl Future<Output = Result<Vec<O>, Error>>
where (O,): for<'r> FromRow<'r, <Self::DB as Database>::Row>,
E: 'c + Executor<'c, Database = Self::DB>,
O: Send + Unpin;
fn page_scalars<'e, 'c: 'e, E, O>(
&self,
executor: E,
field: &'c Column,
page: &PageRequest,
) -> impl Future<Output = Result<PageResult<O>, Error>>
where (O,): for<'r> FromRow<'r, <Self::DB as Database>::Row>,
E: 'e + Executor<'c, Database = Self::DB>,
O: Send + Unpin;
}
Required Associated Types§
Required Methods§
Sourcefn one<'e, 'c: 'e, E, O>(
&self,
executor: E,
) -> impl Future<Output = Result<O, Error>>
fn one<'e, 'c: 'e, E, O>( &self, executor: E, ) -> impl Future<Output = Result<O, Error>>
获取一条记录
Sourcefn optional<'e, 'c: 'e, E, O>(
&self,
executor: E,
) -> impl Future<Output = Result<Option<O>, Error>>
fn optional<'e, 'c: 'e, E, O>( &self, executor: E, ) -> impl Future<Output = Result<Option<O>, Error>>
获取一条记录,如果不存在返回 None
Sourcefn all<'e, 'c: 'e, E, O>(
&self,
executor: E,
) -> impl Future<Output = Result<Vec<O>, Error>>
fn all<'e, 'c: 'e, E, O>( &self, executor: E, ) -> impl Future<Output = Result<Vec<O>, Error>>
获取全部记录
Sourcefn map_all<'e, 'c: 'e, E, O, F, K>(
&self,
executor: E,
key_fn: F,
) -> impl Future<Output = Result<HashMap<K, O>, Error>>
fn map_all<'e, 'c: 'e, E, O, F, K>( &self, executor: E, key_fn: F, ) -> impl Future<Output = Result<HashMap<K, O>, Error>>
以 map 形式返回全部记录
Sourcefn page<'e, 'c: 'e, E, O>(
&self,
executor: E,
page: &PageRequest,
) -> impl Future<Output = Result<PageResult<O>, Error>>
fn page<'e, 'c: 'e, E, O>( &self, executor: E, page: &PageRequest, ) -> impl Future<Output = Result<PageResult<O>, Error>>
分页查询
Sourcefn one_scalar<'q, 'c, E, O>(
&self,
executor: E,
field: &'q Column,
) -> impl Future<Output = Result<O, Error>>
fn one_scalar<'q, 'c, E, O>( &self, executor: E, field: &'q Column, ) -> impl Future<Output = Result<O, Error>>
获取一个标量
Sourcefn optional_scalar<'q, 'c, E, O>(
&self,
executor: E,
field: &'q Column,
) -> impl Future<Output = Result<Option<O>, Error>>
fn optional_scalar<'q, 'c, E, O>( &self, executor: E, field: &'q Column, ) -> impl Future<Output = Result<Option<O>, Error>>
获取一个可选标量,如果不存在返回 None
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.