use sea_orm::entity::prelude::*;
#[sea_orm::model]
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
#[sea_orm(table_name = "workspaces")]
pub struct Model {
#[sea_orm(primary_key, auto_increment = true)]
pub id: i32,
#[sea_orm(unique)]
pub name: String,
#[sea_orm(nullable)]
pub number: Option<i32>,
#[sea_orm(nullable)]
pub output: Option<String>,
#[sea_orm(default = false)]
pub is_global: bool,
#[sea_orm(nullable)]
pub created_at: Option<DateTime>,
#[sea_orm(nullable)]
pub updated_at: Option<DateTime>,
}
impl ActiveModelBehavior for ActiveModel {}
impl Entity {
pub fn find_by_number(number: i32) -> Select<Self> {
Self::find().filter(Column::Number.eq(number))
}
pub fn find_by_output(output: &str) -> Select<Self> {
Self::find().filter(Column::Output.eq(output))
}
pub fn find_global() -> Select<Self> {
Self::find().filter(Column::IsGlobal.eq(true))
}
}