pub trait Model<T>: TryFrom<Row, Error = Error> {
// Required methods
fn columns() -> &'static [&'static dyn Deref<Target = Column>];
fn table_name() -> &'static str;
fn select<'a>() -> Select<'a, Vec<T>>;
fn select_one<'a>() -> Select<'a, Option<T>>;
fn update<'a>() -> Update<'a>;
fn delete<'a>() -> Delete<'a>;
fn query<'a>(
_: impl Into<String>,
_: Vec<&'a (dyn ToSql + Sync)>
) -> Query<'a, Vec<T>>;
}Expand description
This is the trait which you should derive for your model structs.
It provides the ORM functionality.
Required Methods§
sourcefn columns() -> &'static [&'static dyn Deref<Target = Column>]
fn columns() -> &'static [&'static dyn Deref<Target = Column>]
Returns a slice of all columns this model’s table has.
sourcefn table_name() -> &'static str
fn table_name() -> &'static str
Returns the name of this model’s table’s name.
sourcefn select<'a>() -> Select<'a, Vec<T>>
fn select<'a>() -> Select<'a, Vec<T>>
Start building a SELECT query which will be parsed to this model.
sourcefn select_one<'a>() -> Select<'a, Option<T>>
fn select_one<'a>() -> Select<'a, Option<T>>
Start building a SELECT query which returns either
one entity or None.
sourcefn update<'a>() -> Update<'a>
fn update<'a>() -> Update<'a>
Start building an UPDATE query.
Returns the number of rows affected.