Trait spanner_rs::TransactionContext [−][src]
pub trait TransactionContext: ReadContext {
fn execute_update<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 mut self,
statement: &'life1 str,
parameters: &'life2 [(&'life3 str, &'life4 (dyn ToSpanner + Sync))]
) -> Pin<Box<dyn Future<Output = Result<i64, Error>> + Send + 'async_trait>>
where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
Self: 'async_trait;
}Expand description
Defines the interface to read from and write into Cloud Spanner.
This extends ReadContext to provide additional write functionalities.
Required methods
fn execute_update<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 mut self,
statement: &'life1 str,
parameters: &'life2 [(&'life3 str, &'life4 (dyn ToSpanner + Sync))]
) -> Pin<Box<dyn Future<Output = Result<i64, Error>> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
Self: 'async_trait,
fn execute_update<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 mut self,
statement: &'life1 str,
parameters: &'life2 [(&'life3 str, &'life4 (dyn ToSpanner + Sync))]
) -> Pin<Box<dyn Future<Output = Result<i64, Error>> + Send + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
Self: 'async_trait,
Execute a read-only SQL statement and returns the number of affected rows.
Parameters
Like its ReadContext::execute_sql counterpart, this function also supports query parameters.
Example
let id = 42;
let name = "ferris";
let rows = tx.execute_update(
"INSERT INTO person(id, name) VALUES (@id, @name)",
&[("id", &id), ("name", name)]
).await?;
println!("Inserted {} row", rows);