[][src]Trait butane_core::DataObject

pub trait DataObject: DataResult<DBO = Self> {
    type PKType: PrimaryKeyType;
    type Fields: Default;

    pub const PKCOL: &'static str;
    pub const TABLE: &'static str;

    pub fn pk(&self) -> &Self::PKType;
pub fn save(&mut self, conn: &impl ConnectionMethods) -> Result<()>;
pub fn delete(&self, conn: &impl ConnectionMethods) -> Result<()>; pub fn get(
        conn: &impl ConnectionMethods,
        id: impl Borrow<Self::PKType>
    ) -> Result<Self>
    where
        Self: Sized
, { ... } }

An object in the database.

Rather than implementing this type manually, use the #[model] attribute.

Associated Types

type PKType: PrimaryKeyType[src]

The type of the primary key field.

type Fields: Default[src]

Loading content...

Associated Constants

pub const PKCOL: &'static str[src]

The name of the primary key column.

pub const TABLE: &'static str[src]

The name of the table.

Loading content...

Required methods

pub fn pk(&self) -> &Self::PKType[src]

Get the primary key

pub fn save(&mut self, conn: &impl ConnectionMethods) -> Result<()>[src]

Save the object to the database.

pub fn delete(&self, conn: &impl ConnectionMethods) -> Result<()>[src]

Delete the object from the database.

Loading content...

Provided methods

pub fn get(
    conn: &impl ConnectionMethods,
    id: impl Borrow<Self::PKType>
) -> Result<Self> where
    Self: Sized
[src]

Find this object in the database based on primary key.

Loading content...

Implementors

Loading content...