Model

Trait Model 

Source
pub trait Model {
    // Required methods
    fn table_name() -> &'static str;
    fn columns() -> Vec<ColumnInfo>;
    fn active_columns() -> Vec<&'static str>;
    fn to_map(&self) -> HashMap<String, String>;
}
Expand description

The core trait defining a Database Model (Table) in Bottle ORM.

This trait is typically implemented automatically via the #[derive(Model)] macro.

§Example

use bottle_orm::Model;

#[derive(Model)]
struct User {
    #[orm(primary_key)]
    id: i32,
    username: String,
}

Required Methods§

Source

fn table_name() -> &'static str

Returns the table name associated with this model. usually converted from CamelCase struct name to snake_case.

Source

fn columns() -> Vec<ColumnInfo>

Returns the list of column definitions for this model.

Source

fn active_columns() -> Vec<&'static str>

Returns the names of active columns (struct fields).

Source

fn to_map(&self) -> HashMap<String, String>

Converts the model instance into a value map (Column Name -> String Value). Used primarily for INSERT operations.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§