Trait derive_sql::Sqlable
source · pub trait Sqlable {
type Item;
type Error;
type Selector;
// Required methods
fn count(&self, s: Self::Selector) -> Result<usize, Self::Error>;
fn select(&self, s: Self::Selector) -> Result<Vec<Self::Item>, Self::Error>;
fn insert(&mut self, item: Self::Item) -> Result<Self::Item, Self::Error>;
fn update(
&mut self,
s: Self::Selector,
item: Self::Item
) -> Result<Self::Item, Self::Error>;
fn delete(&mut self, s: Self::Selector) -> Result<(), Self::Error>;
fn delete_table(&mut self) -> Result<(), Self::Error>;
}Expand description
Definition of Sqlable trait to be implemented to allow interaction with SQL tables.
Required Associated Types§
Required Methods§
sourcefn count(&self, s: Self::Selector) -> Result<usize, Self::Error>
fn count(&self, s: Self::Selector) -> Result<usize, Self::Error>
Count the number of items in the table meeting the selector requirements
sourcefn select(&self, s: Self::Selector) -> Result<Vec<Self::Item>, Self::Error>
fn select(&self, s: Self::Selector) -> Result<Vec<Self::Item>, Self::Error>
Retrieve the array of items in the table meeting the selector requirements
sourcefn insert(&mut self, item: Self::Item) -> Result<Self::Item, Self::Error>
fn insert(&mut self, item: Self::Item) -> Result<Self::Item, Self::Error>
Insert a new item in the table and returned the inserted item.
sourcefn update(
&mut self,
s: Self::Selector,
item: Self::Item
) -> Result<Self::Item, Self::Error>
fn update( &mut self, s: Self::Selector, item: Self::Item ) -> Result<Self::Item, Self::Error>
Update items meeting the selector requirements with the values of the provided item. Returns the array of items modified with their updated value
sourcefn delete(&mut self, s: Self::Selector) -> Result<(), Self::Error>
fn delete(&mut self, s: Self::Selector) -> Result<(), Self::Error>
Delete items in the table meeting the selector requirements
sourcefn delete_table(&mut self) -> Result<(), Self::Error>
fn delete_table(&mut self) -> Result<(), Self::Error>
Delete the table from the database