pub struct Transaction<'connection> { /* private fields */ }Expand description
Typed ORM executor bound to one SQLite transaction.
Implementations§
Source§impl Transaction<'_>
impl Transaction<'_>
Sourcepub fn execute(&self, ast: QueryAst) -> Result<ExecuteResult, OrmError>
pub fn execute(&self, ast: QueryAst) -> Result<ExecuteResult, OrmError>
Executes a validated ORM query AST.
Sourcepub fn insert<M: Model>(&self, model: &M) -> Result<ExecuteResult, OrmError>
pub fn insert<M: Model>(&self, model: &M) -> Result<ExecuteResult, OrmError>
Inserts a model, omitting its primary key and managed timestamps.
Sourcepub fn fetch_all<M: Model>(
&self,
query: SelectQuery<M>,
) -> Result<Vec<M>, OrmError>
pub fn fetch_all<M: Model>( &self, query: SelectQuery<M>, ) -> Result<Vec<M>, OrmError>
Fetches all rows matching a typed select query.
Sourcepub fn fetch_one<M: Model>(
&self,
query: SelectQuery<M>,
) -> Result<Option<M>, OrmError>
pub fn fetch_one<M: Model>( &self, query: SelectQuery<M>, ) -> Result<Option<M>, OrmError>
Fetches at most one row matching a typed select query.
Sourcepub fn get<M: Model>(&self, id: i64) -> Result<Option<M>, OrmError>
pub fn get<M: Model>(&self, id: i64) -> Result<Option<M>, OrmError>
Fetches a model by its generated integer primary key.
Sourcepub fn create<M: Model>(&self) -> TransactionCreateBuilder<'_, M>
pub fn create<M: Model>(&self) -> TransactionCreateBuilder<'_, M>
Starts a typed insert builder bound to this transaction.
Sourcepub fn update<M: Model>(&self, id: i64) -> TransactionUpdateBuilder<'_, M>
pub fn update<M: Model>(&self, id: i64) -> TransactionUpdateBuilder<'_, M>
Starts a typed update builder scoped to one primary key.
Sourcepub fn query<M: Model>(&self) -> TransactionQuery<'_, M>
pub fn query<M: Model>(&self) -> TransactionQuery<'_, M>
Returns the typed select-query facade for this transaction.
Auto Trait Implementations§
impl<'connection> !RefUnwindSafe for Transaction<'connection>
impl<'connection> !Send for Transaction<'connection>
impl<'connection> !Sync for Transaction<'connection>
impl<'connection> !UnwindSafe for Transaction<'connection>
impl<'connection> Freeze for Transaction<'connection>
impl<'connection> Unpin for Transaction<'connection>
impl<'connection> UnsafeUnpin for Transaction<'connection>
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