Skip to main content

Transaction

Struct Transaction 

Source
pub struct Transaction { /* private fields */ }
Expand description

ORM operations pinned to one transaction connection on either backend.

Implementations§

Source§

impl Transaction

Source

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.

Source

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.

Source

pub async fn execute(&self, ast: QueryAst) -> Result<ExecuteResult, OrmError>

Source

pub async fn insert<M: Model>( &self, model: &M, ) -> Result<ExecuteResult, OrmError>

Source

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.

Source

pub async fn fetch_all<M: Model + Send + 'static>( &self, query: SelectQuery<M>, ) -> Result<Vec<M>, OrmError>

Source

pub async fn fetch_one<M: Model + Send + 'static>( &self, query: SelectQuery<M>, ) -> Result<Option<M>, OrmError>

Source

pub async fn get<M: Model + Send + 'static>( &self, id: M::PrimaryKey, ) -> Result<Option<M>, OrmError>

Source

pub async fn all<M: Model + Send + 'static>(&self) -> Result<Vec<M>, OrmError>

Source

pub async fn count<M: Model + Send + 'static>(&self) -> Result<usize, OrmError>

Source

pub async fn delete<M: Model + Send + 'static>( &self, id: M::PrimaryKey, ) -> Result<bool, OrmError>

Source

pub fn create<M: Model>(&self) -> TransactionCreateBuilder<'_, M>

Source

pub fn update<M: Model>( &self, id: M::PrimaryKey, ) -> TransactionUpdateBuilder<'_, M>

Source

pub fn query<M: Model>(&self) -> TransactionQuery<'_, M>

Source

pub async fn fetch_by_many<M, T, I, V>( &self, field: ModelField<M, T>, values: I, ) -> Result<Vec<M>, OrmError>
where M: Model + Send + 'static, I: IntoIterator<Item = V>, V: QueryValue<T>,

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.