Trait QueryBuilder

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

Source

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,

获取一条记录

Source

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,

获取一条记录,如果不存在返回 None

Source

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,

获取全部记录

Source

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,

以 map 形式返回全部记录

Source

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,

分页查询

Source

fn count<'c, E>( &self, executor: E, ) -> impl Future<Output = Result<usize, Error>>
where E: 'c + Executor<'c, Database = Self::DB>,

查询记录数

Source

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,

获取一个标量

Source

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,

获取一个可选标量,如果不存在返回 None

Source

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,

获取全部标量

Source

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,

分页获取标量

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.

Implementors§