//! Generated by `rustio startapp {{name}}`. Customise freely.
{{imports}}
#[derive(RustioAdmin)]
pub struct {{Singular}} {
pub id: i64,
{{struct_fields}}
}
impl Model for {{Singular}} {
const TABLE: &'static str = "{{table}}";
const COLUMNS: &'static [&'static str] = &[{{columns_literal}}];
const INSERT_COLUMNS: &'static [&'static str] = &[{{insert_columns_literal}}];
fn id(&self) -> i64 {
self.id
}
fn from_row(row: Row<'_>) -> Result<Self, Error> {
Ok(Self {
id: row.get_i64("id")?,
{{from_row_assignments}}
})
}
fn insert_values(&self) -> Vec<Value> {
vec![{{insert_values_expr}}]
}
}
// The `ModelAdmin` impl below customises the admin list / form
// surface for `{{Singular}}`. Every method has a sensible default;
// these starter overrides reflect the fields you declared with
// `--field` at scaffold time. Edit freely.
impl ModelAdmin for {{Singular}} {
/// Columns shown in the list-page table. Order matches the
/// `--field` declaration order.
fn list_display() -> &'static [&'static str] {
&[{{list_display_literal}}]
}
/// Columns whose `=` value is filterable via `?filter_<col>=<v>`
/// chips above the list page. Strings, enums, and small-cardinality
/// columns make the most sense here.
fn list_filter() -> &'static [&'static str] {
// Example: filter the list by a status enum.
// &["status"]
&[]
}
/// Columns that the list-page `?q=...` search box matches with
/// `ILIKE`. Defaulted to the text-shaped fields you declared
/// (`str` / `text`); leave empty if none.
fn search_fields() -> &'static [&'static str] {
&[{{search_fields_literal}}]
}
/// Default sort order. Prefix with `-` for descending.
fn ordering() -> &'static [&'static str] {
&["-id"]
}
}