Struct rustorm::em::EntityManager
[−]
[src]
pub struct EntityManager<'a> { pub db: &'a Database, }
A higher level API for manipulating objects in the database This serves as a helper function for the query api
Fields
db |
Methods
impl<'a> EntityManager<'a>
fn new(db: &'a Database) -> Self
Create an entity manager with the database connection provided
fn delete(&self, table: &Table, filters: Vec<Filter>) -> usize
delete records of this table
fn get_all<T>(&self) -> Result<Vec<T>, DbError> where T: IsTable + IsDao
get all the records of this table
fn get_all_only_columns<T>(&self, columns: Vec<&str>) -> Result<Vec<T>, DbError> where T: IsTable + IsDao
get all the records of this table, but return only the columns mentioned
fn get_all_ignore_columns<T>(&self, ignore_columns: Vec<&str>) -> Result<Vec<T>, DbError> where T: IsTable + IsDao
get all the records of this table, ignoring the columns listed, mentioned the other else
fn get_all_distinct<T>(&self) -> Result<Vec<T>, DbError> where T: IsTable + IsDao
get all the distinct records of this table
fn get_all_with_filter<T>(&self, filters: Vec<Filter>) -> Result<Vec<T>, DbError> where T: IsTable + IsDao
get all the records on this table which passed thru the filters any query that specified more than the parameters should use the query api
fn get_one<T>(&self, filter: Filter) -> Result<T, DbError> where T: IsTable + IsDao
get the first records of this table that passed thru the filters
fn get_exact<T>(&self, id: &ToValue) -> Result<T, DbError> where T: IsTable + IsDao
get an exact match, the value is filter against the primary key of the table
fn insert<T>(&self, dao: Dao) -> Result<T, DbError> where T: IsTable + IsDao
fn insert_with_ignore_columns<T>(&self, dao: Dao, ignore_columns: Vec<&str>) -> Result<T, DbError> where T: IsTable + IsDao
insert this record on the database, ignoring some columns which are set by the database default columns that are ignored are set by the database automatically
fn insert_ignore_defaulted_columns<T>(&self, _dao: Dao) -> Result<T, DbError> where T: IsTable + IsDao
insert this record on the database, explicitly setting the defaults of the columns
it may produce the same result with insert_with_ignore_columns
the query is different since it may mentions created
now(),
fn reset(&self)
this is called when there is a problem with the transaction
fn rollback(&self)
when there is a problem with the transaction process, this can be called
fn update<T>(&self, _dao: &Dao) -> Result<T, DbError> where T: IsTable + IsDao
update the Dao, return the updated Dao
fn update_ignore_columns<T>(&self, _dao: &Dao, _ignore_columns: Vec<&str>) -> Result<T, DbError> where T: IsTable + IsDao
update the Dao, return the updated Dao ignored columns will remain unchanged
fn update_only_columns<T>(&self, _dao: &Dao, _columns: Vec<&str>) -> Result<T, DbError> where T: IsTable + IsDao
update the Dao, return the updated Dao only the columns specified, the rest is unchanged
fn update_ignore_defaulted_columns<T>(&self, _dao: &Dao) -> Result<T, DbError> where T: IsTable + IsDao
update the Dao, return the updated Dao the default columns will be reset to whatever the db's default function will come up. ie. updated column will be defaulted everytime a record is updated.
fn update_with_filter<T>(&self, _dao: &Dao, _filter: Vec<Filter>) -> Result<T, DbError> where T: IsTable + IsDao
update the Dao with filter, return the updated Dao
fn save<T>(&self, _dao: T) -> Result<T, DbError> where T: IsTable + IsDao
whether to use insert or update insert when it is a new record update when it is an existing recor may use UPSERT in newer versions of postgres may use MERGE in oracle, mssql