Trait butane_core::db::ConnectionMethods
source · pub trait ConnectionMethods {
// Required methods
fn execute(&self, sql: &str) -> Result<()>;
fn query<'a, 'b, 'c: 'a>(
&'c self,
table: &str,
columns: &'b [Column],
expr: Option<BoolExpr>,
limit: Option<i32>,
offset: Option<i32>,
sort: Option<&[Order]>
) -> Result<RawQueryResult<'a>>;
fn insert_returning_pk(
&self,
table: &str,
columns: &[Column],
pkcol: &Column,
values: &[SqlValRef<'_>]
) -> Result<SqlVal>;
fn insert_only(
&self,
table: &str,
columns: &[Column],
values: &[SqlValRef<'_>]
) -> Result<()>;
fn insert_or_replace(
&self,
table: &str,
columns: &[Column],
pkcol: &Column,
values: &[SqlValRef<'_>]
) -> Result<()>;
fn update(
&self,
table: &str,
pkcol: Column,
pk: SqlValRef<'_>,
columns: &[Column],
values: &[SqlValRef<'_>]
) -> Result<()>;
fn delete_where(&self, table: &str, expr: BoolExpr) -> Result<usize>;
fn has_table(&self, table: &str) -> Result<bool>;
// Provided method
fn delete(&self, table: &str, pkcol: &'static str, pk: SqlVal) -> Result<()> { ... }
}
Expand description
Methods available on a database connection. Most users do not need
to call these methods directly and will instead use methods on
DataObject or the query!
macro. This trait is
implemented by both database connections and transactions.
Required Methods§
fn execute(&self, sql: &str) -> Result<()>
fn query<'a, 'b, 'c: 'a>( &'c self, table: &str, columns: &'b [Column], expr: Option<BoolExpr>, limit: Option<i32>, offset: Option<i32>, sort: Option<&[Order]> ) -> Result<RawQueryResult<'a>>
fn insert_returning_pk( &self, table: &str, columns: &[Column], pkcol: &Column, values: &[SqlValRef<'_>] ) -> Result<SqlVal>
sourcefn insert_only(
&self,
table: &str,
columns: &[Column],
values: &[SqlValRef<'_>]
) -> Result<()>
fn insert_only( &self, table: &str, columns: &[Column], values: &[SqlValRef<'_>] ) -> Result<()>
Like insert_returning_pk
but with no return value
sourcefn insert_or_replace(
&self,
table: &str,
columns: &[Column],
pkcol: &Column,
values: &[SqlValRef<'_>]
) -> Result<()>
fn insert_or_replace( &self, table: &str, columns: &[Column], pkcol: &Column, values: &[SqlValRef<'_>] ) -> Result<()>
Insert unless there’s a conflict on the primary key column, in which case update