Transaction

Struct Transaction 

Source
pub struct Transaction<'a, G>
where G: SqlGenerator + Sync + Debug,
{ /* private fields */ }

Implementations§

Source§

impl<'a, G> Transaction<'a, G>
where G: SqlGenerator + Sync + Debug,

Source

pub fn new(trx: Transaction<'a, Any>, sql_generator: &'a G) -> Self

Source

pub async fn commit(self) -> Result<(), LunaOrmError>

Source

pub async fn rollback(self) -> Result<(), LunaOrmError>

Source

pub async fn query(&mut self, sql: &str) -> Result<usize, LunaOrmError>

Source

pub async fn remove<SE>( &mut self, primary: &dyn Primary, selection: &dyn Selection, ) -> LunaOrmResult<Option<SE>>
where SE: SelectedEntity + Send + Unpin,

Trait Implementations§

Source§

impl<'a, G> CommandExecutor for Transaction<'a, G>
where G: SqlGenerator + Sync + Debug,

Source§

type G = G

Source§

fn get_generator(&self) -> &Self::G

Source§

async fn select<SE>( &mut self, primary: &dyn Primary, selection: &dyn Selection, ) -> LunaOrmResult<Option<SE>>
where SE: SelectedEntity + Send + Unpin,

Source§

async fn create<'a>( &mut self, entity: &'a mut dyn Entity, ) -> LunaOrmResult<bool>

Source§

async fn insert(&mut self, entity: &dyn Entity) -> LunaOrmResult<bool>

Source§

async fn upsert(&mut self, entity: &dyn Entity) -> LunaOrmResult<bool>

Source§

async fn update( &mut self, mutation: &dyn Mutation, primary: &dyn Primary, ) -> LunaOrmResult<bool>

Source§

async fn delete(&mut self, primary: &dyn Primary) -> LunaOrmResult<bool>

Source§

async fn search_all<SE>( &mut self, selection: &dyn Selection, ) -> LunaOrmResult<Vec<SE>>
where SE: SelectedEntity + Send + Unpin,

Source§

async fn search<SE>( &mut self, location: &dyn Location, order_by: Option<&dyn OrderBy>, selection: &dyn Selection, ) -> LunaOrmResult<Vec<SE>>
where SE: SelectedEntity + Send + Unpin,

Source§

async fn count(&mut self, location: &dyn Location) -> LunaOrmResult<usize>

Source§

async fn search_paged<SE>( &mut self, location: &dyn Location, order_by: Option<&dyn OrderBy>, selection: &dyn Selection, page: &Pagination, ) -> LunaOrmResult<PagedList<SE>>
where SE: SelectedEntity + Send + Unpin,

Source§

async fn search_joined<SE>( &mut self, joined_conds: JoinedConditions, locations: Vec<&dyn Location>, order_by: Option<&dyn OrderBy>, selections: Vec<&dyn Selection>, page: &Pagination, ) -> String

Source§

async fn purify(&mut self, location: &dyn Location) -> LunaOrmResult<usize>

Source§

async fn change( &mut self, mutation: &dyn Mutation, location: &dyn Location, ) -> LunaOrmResult<usize>

Source§

async fn execute_by_template( &mut self, template: &dyn TemplateRecord, ) -> LunaOrmResult<usize>

Source§

async fn select_by_template<SE>( &mut self, template: &dyn TemplateRecord, ) -> LunaOrmResult<Option<SE>>
where SE: SelectedEntity + Send + Unpin,

Source§

async fn search_by_template<SE>( &mut self, template: &dyn TemplateRecord, ) -> LunaOrmResult<Vec<SE>>
where SE: SelectedEntity + Send + Unpin,

Source§

async fn search_paged_by_template<SE>( &mut self, template: &dyn TemplateRecord, page: &Pagination, ) -> LunaOrmResult<PagedList<SE>>
where SE: SelectedEntity + Send + Unpin,

Source§

impl<'a, G> Debug for Transaction<'a, G>
where G: SqlGenerator + Sync + Debug + Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a, G> SqlExecutor for Transaction<'a, G>
where G: SqlGenerator + Sync + Debug,

Source§

async fn fetch_optional<SE>( &mut self, stmt: &str, args: AnyArguments<'_>, ) -> LunaOrmResult<Option<SE>>
where SE: SelectedEntity + Send + Unpin,

Source§

async fn fetch_all<SE>( &mut self, stmt: &str, args: AnyArguments<'_>, ) -> LunaOrmResult<Vec<SE>>
where SE: SelectedEntity + Send + Unpin,

Source§

async fn fetch_all_plain<SE>(&mut self, stmt: &str) -> LunaOrmResult<Vec<SE>>
where SE: SelectedEntity + Send + Unpin,

Source§

async fn execute( &mut self, stmt: &str, args: AnyArguments<'_>, ) -> LunaOrmResult<AnyQueryResult>

Source§

async fn execute_plain(&mut self, stmt: &str) -> LunaOrmResult<AnyQueryResult>

Source§

fn get_pool(&self) -> LunaOrmResult<&AnyPool>

Source§

async fn fetch_one_plain<SE>(&mut self, stmt: &str) -> LunaOrmResult<SE>
where SE: SelectedEntity + Send + Unpin,

Source§

async fn fetch_one<SE>( &mut self, stmt: &str, args: AnyArguments<'_>, ) -> LunaOrmResult<SE>
where SE: SelectedEntity + Send + Unpin,

Source§

async fn fetch_optional_plain<SE>( &mut self, stmt: &str, ) -> LunaOrmResult<Option<SE>>
where SE: SelectedEntity + Send + Unpin,

Auto Trait Implementations§

§

impl<'a, G> Freeze for Transaction<'a, G>

§

impl<'a, G> !RefUnwindSafe for Transaction<'a, G>

§

impl<'a, G> Send for Transaction<'a, G>

§

impl<'a, G> !Sync for Transaction<'a, G>

§

impl<'a, G> Unpin for Transaction<'a, G>

§

impl<'a, G> !UnwindSafe for Transaction<'a, G>

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more