Struct akita::AkitaEntityManager
source · [−]pub struct AkitaEntityManager(_, _);
Expand description
an interface executing sql statement and getting the results as generic Akita values without any further conversion.
Implementations
sourceimpl AkitaEntityManager
impl AkitaEntityManager
pub fn new(db: PlatformPool, cfg: AkitaConfig) -> Self
pub fn acquire(&self) -> Result<DatabasePlatform, AkitaError>
pub fn set_session_user(&mut self, username: &str) -> Result<(), AkitaError>
sourcepub fn get_table(
&mut self,
table_name: &TableName
) -> Result<Option<TableDef>, AkitaError>
pub fn get_table(
&mut self,
table_name: &TableName
) -> Result<Option<TableDef>, AkitaError>
get the table from database based on this column name
sourcepub fn set_autoincrement_value(
&mut self,
table_name: &TableName,
sequence_value: i64
) -> Result<Option<i64>, AkitaError>
pub fn set_autoincrement_value(
&mut self,
table_name: &TableName,
sequence_value: i64
) -> Result<Option<i64>, AkitaError>
set the autoincrement value of the primary column(if present) of this table. If the primary column of this table is not an autoincrement, returns Ok(None).
pub fn get_autoincrement_last_value(
&mut self,
table_name: &TableName
) -> Result<Option<i64>, AkitaError>
pub fn get_database_name(&mut self) -> Result<Option<DatabaseName>, AkitaError>
Trait Implementations
sourceimpl AkitaMapper for AkitaEntityManager
impl AkitaMapper for AkitaEntityManager
sourcefn list<T>(&self, wrapper: Wrapper) -> Result<Vec<T>, AkitaError>where
T: GetTableName + GetFields + FromValue,
fn list<T>(&self, wrapper: Wrapper) -> Result<Vec<T>, AkitaError>where
T: GetTableName + GetFields + FromValue,
Get all the table of records
sourcefn select_one<T>(&self, wrapper: Wrapper) -> Result<Option<T>, AkitaError>where
T: GetTableName + GetFields + FromValue,
fn select_one<T>(&self, wrapper: Wrapper) -> Result<Option<T>, AkitaError>where
T: GetTableName + GetFields + FromValue,
Get one the table of records
sourcefn select_by_id<T, I>(&self, id: I) -> Result<Option<T>, AkitaError>where
T: GetTableName + GetFields + FromValue,
I: ToValue,
fn select_by_id<T, I>(&self, id: I) -> Result<Option<T>, AkitaError>where
T: GetTableName + GetFields + FromValue,
I: ToValue,
Get one the table of records by id
sourcefn page<T>(
&self,
page: usize,
size: usize,
wrapper: Wrapper
) -> Result<IPage<T>, AkitaError>where
T: GetTableName + GetFields + FromValue,
fn page<T>(
&self,
page: usize,
size: usize,
wrapper: Wrapper
) -> Result<IPage<T>, AkitaError>where
T: GetTableName + GetFields + FromValue,
Get table of records with page
sourcefn count<T>(&self, wrapper: Wrapper) -> Result<usize, AkitaError>where
T: GetTableName + GetFields,
fn count<T>(&self, wrapper: Wrapper) -> Result<usize, AkitaError>where
T: GetTableName + GetFields,
Get the total count of records
sourcefn remove<T>(&self, wrapper: Wrapper) -> Result<u64, AkitaError>where
T: GetTableName + GetFields,
fn remove<T>(&self, wrapper: Wrapper) -> Result<u64, AkitaError>where
T: GetTableName + GetFields,
Remove the records by wrapper.
sourcefn remove_by_id<T, I>(&self, id: I) -> Result<u64, AkitaError>where
I: ToValue,
T: GetTableName + GetFields,
fn remove_by_id<T, I>(&self, id: I) -> Result<u64, AkitaError>where
I: ToValue,
T: GetTableName + GetFields,
Remove the records by id.
sourcefn remove_by_ids<T, I>(&self, ids: Vec<I>) -> Result<u64, AkitaError>where
I: ToValue,
T: GetTableName + GetFields,
fn remove_by_ids<T, I>(&self, ids: Vec<I>) -> Result<u64, AkitaError>where
I: ToValue,
T: GetTableName + GetFields,
Remove the records by wrapper.
sourcefn update<T>(&self, entity: &T, wrapper: Wrapper) -> Result<u64, AkitaError>where
T: GetTableName + GetFields + ToValue,
fn update<T>(&self, entity: &T, wrapper: Wrapper) -> Result<u64, AkitaError>where
T: GetTableName + GetFields + ToValue,
Update the records by wrapper.
sourcefn update_by_id<T>(&self, entity: &T) -> Result<u64, AkitaError>where
T: GetTableName + GetFields + ToValue,
fn update_by_id<T>(&self, entity: &T) -> Result<u64, AkitaError>where
T: GetTableName + GetFields + ToValue,
Update the records by id.
sourcefn save<T, I>(&self, entity: &T) -> Result<Option<I>, AkitaError>where
T: GetTableName + GetFields + ToValue,
I: FromValue,
fn save<T, I>(&self, entity: &T) -> Result<Option<I>, AkitaError>where
T: GetTableName + GetFields + ToValue,
I: FromValue,
called multiple times when using database platform that doesn;t support multiple value
sourcefn save_or_update<T, I>(&self, entity: &T) -> Result<Option<I>, AkitaError>where
T: GetTableName + GetFields + ToValue,
I: FromValue,
fn save_or_update<T, I>(&self, entity: &T) -> Result<Option<I>, AkitaError>where
T: GetTableName + GetFields + ToValue,
I: FromValue,
save or update
fn save_batch<T>(&self, entities: &[&T]) -> Result<(), AkitaError>where
T: GetTableName + GetFields + ToValue,
fn exec_iter<S: Into<String>, P: Into<Params>>(
&self,
sql: S,
params: P
) -> Result<Rows, AkitaError>
fn query<T, Q>(&mut self, query: Q) -> Result<Vec<T>, AkitaError>where
Q: Into<String>,
T: FromValue,
fn query_opt<T, Q>(
&mut self,
query: Q
) -> Result<Vec<Result<T, AkitaDataError>>, AkitaError>where
Q: Into<String>,
T: FromValue,
fn query_first<S: Into<String>, R>(&self, sql: S) -> Result<R, AkitaError>where
R: FromValue,
fn query_first_opt<R, S: Into<String>>(
&self,
sql: S
) -> Result<Option<R>, AkitaError>where
R: FromValue,
fn query_map<T, F, Q, U>(&self, query: Q, f: F) -> Result<Vec<U>, AkitaError>where
Q: Into<String>,
T: FromValue,
F: FnMut(T) -> U,
fn query_fold<T, F, Q, U>(&self, query: Q, init: U, f: F) -> Result<U, AkitaError>where
Q: Into<String>,
T: FromValue,
F: FnMut(U, T) -> U,
fn query_drop<Q>(&mut self, query: Q) -> Result<(), AkitaError>where
Q: Into<String>,
fn exec_map<T, F, Q, U>(&self, query: Q, f: F) -> Result<Vec<U>, AkitaError>where
Q: Into<String>,
T: FromValue,
F: FnMut(T) -> U,
fn query_iter<S: Into<String>>(&self, sql: S) -> Result<Rows, AkitaError>
fn exec_raw<R, S: Into<String>, P: Into<Params>>(
&self,
sql: S,
params: P
) -> Result<Vec<R>, AkitaError>where
R: FromValue,
fn exec_first<R, S: Into<String>, P: Into<Params>>(
&self,
sql: S,
params: P
) -> Result<R, AkitaError>where
R: FromValue,
fn exec_drop<S: Into<String>, P: Into<Params>>(
&self,
sql: S,
params: P
) -> Result<(), AkitaError>
fn exec_first_opt<R, S: Into<String>, P: Into<Params>>(
&self,
sql: S,
params: P
) -> Result<Option<R>, AkitaError>where
R: FromValue,
Auto Trait Implementations
impl !RefUnwindSafe for AkitaEntityManager
impl Send for AkitaEntityManager
impl Sync for AkitaEntityManager
impl Unpin for AkitaEntityManager
impl !UnwindSafe for AkitaEntityManager
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more