Trait butane_core::DataObject
source · pub trait DataObject: DataResult<DBO = Self> {
type PKType: PrimaryKeyType;
type Fields: Default;
const PKCOL: &'static str;
const TABLE: &'static str;
const AUTO_PK: bool;
// Required methods
fn pk(&self) -> &Self::PKType;
fn save(&mut self, conn: &impl ConnectionMethods) -> Result<()>;
fn delete(&self, conn: &impl ConnectionMethods) -> Result<()>;
// Provided methods
fn get(
conn: &impl ConnectionMethods,
id: impl Borrow<Self::PKType>
) -> Result<Self>
where Self: Sized { ... }
fn try_get(
conn: &impl ConnectionMethods,
id: impl Borrow<Self::PKType>
) -> Result<Option<Self>>
where Self: Sized { ... }
}
Expand description
An object in the database.
Rather than implementing this type manually, use the
#[model]
attribute.
Required Associated Types§
Required Associated Constants§
Required Methods§
sourcefn save(&mut self, conn: &impl ConnectionMethods) -> Result<()>
fn save(&mut self, conn: &impl ConnectionMethods) -> Result<()>
Save the object to the database.
sourcefn delete(&self, conn: &impl ConnectionMethods) -> Result<()>
fn delete(&self, conn: &impl ConnectionMethods) -> Result<()>
Delete the object from the database.