pub struct Table { /* private fields */ }
Expand description
A Table
is used to perform writes, deletes, and other operations to data in base tables.
If you create multiple Table
handles from a single ControllerHandle
, they may share
connections to the Soup workers. For this reason, Table
is not Send
or Sync
. To get a
handle that can be sent to a different thread (i.e., one with its own dedicated connections),
call Table::into_exclusive
.
Implementations§
Source§impl Table
impl Table
Sourcepub fn table_name(&self) -> &str
pub fn table_name(&self) -> &str
Get the name of this base table.
Sourcepub fn columns(&self) -> &[String]
pub fn columns(&self) -> &[String]
Get the list of columns in this base table.
Note that this will not be updated if the underlying recipe changes and adds or removes columns!
Sourcepub fn schema(&self) -> Option<&CreateTableStatement>
pub fn schema(&self) -> Option<&CreateTableStatement>
Get the schema that was used to create this base table.
Note that this will not be updated if the underlying recipe changes and adds or removes columns!
Sourcepub async fn insert<V>(&mut self, u: V) -> Result<(), TableError>
pub async fn insert<V>(&mut self, u: V) -> Result<(), TableError>
Insert a single row of data into this base table.
Sourcepub async fn perform_all<I, V>(&mut self, i: I) -> Result<(), TableError>
pub async fn perform_all<I, V>(&mut self, i: I) -> Result<(), TableError>
Perform multiple operation on this base table.
Sourcepub async fn delete<I>(&mut self, key: I) -> Result<(), TableError>
pub async fn delete<I>(&mut self, key: I) -> Result<(), TableError>
Delete the row with the given key from this base table.
Sourcepub async fn update<V>(
&mut self,
key: Vec<DataType>,
u: V,
) -> Result<(), TableError>
pub async fn update<V>( &mut self, key: Vec<DataType>, u: V, ) -> Result<(), TableError>
Update the row with the given key in this base table.
u
is a set of column-modification pairs, where for each pair (i, m)
, the modification
m
will be applied to column i
of the record with key key
.
Sourcepub async fn insert_or_update<V>(
&mut self,
insert: Vec<DataType>,
update: V,
) -> Result<(), TableError>
pub async fn insert_or_update<V>( &mut self, insert: Vec<DataType>, update: V, ) -> Result<(), TableError>
Perform a insert-or-update on this base table.
If a row already exists for the key in insert
, the existing row will instead be updated
with the modifications in u
(as documented in Table::update
).