pub struct Tables {
pub tables: HashMap<String, Rows>,
/* private fields */
}
Fields§
§tables: HashMap<String, Rows>
Implementations§
Source§impl Tables
impl Tables
pub fn new() -> Self
Sourcepub fn all_row_count(&self) -> usize
pub fn all_row_count(&self) -> usize
Returns the number of rows in all tables.
Sourcepub fn create_row<K: Into<PrimaryKey>>(
&mut self,
table: &str,
key: K,
) -> &mut Row
pub fn create_row<K: Into<PrimaryKey>>( &mut self, table: &str, key: K, ) -> &mut Row
Create a new row in the table with the given primary key.
// With a Primary Key of type `Single`
use crate::substreams_database_change::tables::Tables;
let mut tables = Tables::new();
tables.create_row("myevent", "my_key",);
// With a Primary Key of type `Composite`
use crate::substreams_database_change::tables::Tables;
let mut tables = Tables::new();
tables.create_row("myevent", [("evt_tx_hash", String::from("hello")), ("evt_index", String::from("world"))]);
Sourcepub fn upsert_row<K: Into<PrimaryKey>>(
&mut self,
table: &str,
key: K,
) -> &mut Row
pub fn upsert_row<K: Into<PrimaryKey>>( &mut self, table: &str, key: K, ) -> &mut Row
Upsert (insert or update) a new row in the table with the given primary key.
Note Ensure that the SQL sink driver you use supports upsert operations.
// With a Primary Key of type `Single`
use crate::substreams_database_change::tables::Tables;
let mut tables = Tables::new();
tables.upsert_row("myevent", "my_key",);
// With a Primary Key of type `Composite`
use crate::substreams_database_change::tables::Tables;
let mut tables = Tables::new();
tables.upsert_row("myevent", [("evt_tx_hash", String::from("hello")), ("evt_index", String::from("world"))]);
pub fn update_row<K: Into<PrimaryKey>>( &mut self, table: &str, key: K, ) -> &mut Row
pub fn delete_row<K: Into<PrimaryKey>>( &mut self, table: &str, key: K, ) -> &mut Row
pub fn to_database_changes(self) -> DatabaseChanges
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Tables
impl RefUnwindSafe for Tables
impl Send for Tables
impl Sync for Tables
impl Unpin for Tables
impl UnwindSafe for Tables
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