pub struct Transaction { /* private fields */ }Expand description
ORM operations pinned to one transaction connection on either backend.
Implementations§
Source§impl Transaction
impl Transaction
Sourcepub async fn execute_sql(
&self,
sql: impl Into<String>,
params: Vec<DatabaseValue>,
) -> Result<ExecuteResult, OrmError>
pub async fn execute_sql( &self, sql: impl Into<String>, params: Vec<DatabaseValue>, ) -> Result<ExecuteResult, OrmError>
Executes backend-specific SQL on this transaction with bound values.
Sourcepub async fn query_sql(
&self,
sql: impl Into<String>,
params: Vec<DatabaseValue>,
) -> Result<Vec<Row>, OrmError>
pub async fn query_sql( &self, sql: impl Into<String>, params: Vec<DatabaseValue>, ) -> Result<Vec<Row>, OrmError>
Queries backend-specific SQL on this transaction with bound values.
pub async fn execute(&self, ast: QueryAst) -> Result<ExecuteResult, OrmError>
pub async fn insert<M: Model>( &self, model: &M, ) -> Result<ExecuteResult, OrmError>
Sourcepub async fn save<M: Model + Send + 'static>(
&self,
model: &M,
) -> Result<Option<M>, OrmError>
pub async fn save<M: Model + Send + 'static>( &self, model: &M, ) -> Result<Option<M>, OrmError>
Saves an existing model through this transaction and its configured runtime.
See Database::save for field handling and return semantics.
pub async fn fetch_all<M: Model + Send + 'static>( &self, query: SelectQuery<M>, ) -> Result<Vec<M>, OrmError>
pub async fn fetch_one<M: Model + Send + 'static>( &self, query: SelectQuery<M>, ) -> Result<Option<M>, OrmError>
pub async fn get<M: Model + Send + 'static>( &self, id: M::PrimaryKey, ) -> Result<Option<M>, OrmError>
pub async fn all<M: Model + Send + 'static>(&self) -> Result<Vec<M>, OrmError>
pub async fn count<M: Model + Send + 'static>(&self) -> Result<usize, OrmError>
pub async fn delete<M: Model + Send + 'static>( &self, id: M::PrimaryKey, ) -> Result<bool, OrmError>
pub fn create<M: Model>(&self) -> TransactionCreateBuilder<'_, M>
pub fn update<M: Model>( &self, id: M::PrimaryKey, ) -> TransactionUpdateBuilder<'_, M>
pub fn query<M: Model>(&self) -> TransactionQuery<'_, M>
pub async fn fetch_by_many<M, T, I, V>( &self, field: ModelField<M, T>, values: I, ) -> Result<Vec<M>, OrmError>
Auto Trait Implementations§
impl !RefUnwindSafe for Transaction
impl !UnwindSafe for Transaction
impl Forget for Transaction
impl Freeze for Transaction
impl Move for Transaction
impl Send for Transaction
impl Sync for Transaction
impl Unpin for Transaction
impl UnsafeUnpin for Transaction
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more