pub trait Backend<R, E> where
E: From<ToqlError>, {
fn registry(
&self
) -> Result<RwLockReadGuard<'_, TableMapperRegistry>, ToqlError>;
fn registry_mut(
&mut self
) -> Result<RwLockWriteGuard<'_, TableMapperRegistry>, ToqlError>;
fn roles(&self) -> &HashSet<String>;
fn alias_format(&self) -> AliasFormat;
fn aux_params(&self) -> &HashMap<String, SqlArg>;
fn select_sql<'life0, 'async_trait>(
&'life0 mut self,
sql: Sql
) -> Pin<Box<dyn Future<Output = Result<Vec<R>, E>> + Send + 'async_trait>>
where
'life0: 'async_trait,
Self: 'async_trait;
fn prepare_page(&self, result: &mut BuildResult, page: &Page);
fn select_max_page_size_sql<'life0, 'async_trait>(
&'life0 mut self,
sql: Sql
) -> Pin<Box<dyn Future<Output = Result<u64, E>> + Send + 'async_trait>>
where
'life0: 'async_trait,
Self: 'async_trait;
fn select_count_sql<'life0, 'async_trait>(
&'life0 mut self,
sql: Sql
) -> Pin<Box<dyn Future<Output = Result<u64, E>> + Send + 'async_trait>>
where
'life0: 'async_trait,
Self: 'async_trait;
fn execute_sql<'life0, 'async_trait>(
&'life0 mut self,
sql: Sql
) -> Pin<Box<dyn Future<Output = Result<(), E>> + Send + 'async_trait>>
where
'life0: 'async_trait,
Self: 'async_trait;
fn insert_sql<'life0, 'async_trait>(
&'life0 mut self,
sql: Sql
) -> Pin<Box<dyn Future<Output = Result<Vec<SqlArg>, E>> + Send + 'async_trait>>
where
'life0: 'async_trait,
Self: 'async_trait;
}
Expand description
Backend interface that must be implemented by databases to use the default Toql functions. The Backend is implemented for a Row and Error type It contains database specific callbacks for database independend functions
Required Methods
fn registry(
&self
) -> Result<RwLockReadGuard<'_, TableMapperRegistry>, ToqlError>
fn registry(
&self
) -> Result<RwLockReadGuard<'_, TableMapperRegistry>, ToqlError>
Return the registry with all table mappers
fn registry_mut(
&mut self
) -> Result<RwLockWriteGuard<'_, TableMapperRegistry>, ToqlError>
fn registry_mut(
&mut self
) -> Result<RwLockWriteGuard<'_, TableMapperRegistry>, ToqlError>
Return a mutable registry with all table mappers
fn alias_format(&self) -> AliasFormat
fn alias_format(&self) -> AliasFormat
Return the active alias format. It is used to build all SQL aliases
fn aux_params(&self) -> &HashMap<String, SqlArg>
fn aux_params(&self) -> &HashMap<String, SqlArg>
Return the aux params. These will be used together with the query aux params to resolve aux params in SQL expressions and handlers
Execute a select statement on the database and return a vector of rows
fn prepare_page(&self, result: &mut BuildResult, page: &Page)
fn prepare_page(&self, result: &mut BuildResult, page: &Page)
Modify a builder result, so that page can be loaded This is different for each database LIMIT on MySql or LIMIT OFFSET on Postgres, etc.