#[derive(Model)]
{
// Attributes available to this derive:
#[orm]
}
Expand description
Главный derive-макрос. Генерирует:
impl Model for Tstruct NewT { ... }(без PK и auto-полей)- Методы
find,create,save,delete,all,query, … - Структуру
TColumnsдля DSL-фильтров impl HasColumns for T
§Пример
#[derive(Model, Debug, Clone, Serialize, Deserialize)]
#[orm(table = "users")]
pub struct User {
#[orm(primary_key, auto_increment)]
pub id: i64,
#[orm(unique, index)]
pub email: Email,
pub username: String,
#[orm(default = true)]
pub is_active: bool,
#[orm(auto_now_add)]
pub created_at: DateTime<Utc>,
#[orm(auto_now)]
pub updated_at: DateTime<Utc>,
}