sway_groups_core/db/entities/
workspace.rs1use sea_orm::entity::prelude::*;
4
5#[sea_orm::model]
7#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
8#[sea_orm(table_name = "workspaces")]
9pub struct Model {
10 #[sea_orm(primary_key, auto_increment = true)]
11 pub id: i32,
12
13 #[sea_orm(unique)]
14 pub name: String,
15
16 #[sea_orm(nullable)]
17 pub number: Option<i32>,
18
19 #[sea_orm(nullable)]
20 pub output: Option<String>,
21
22 #[sea_orm(default = false)]
23 pub is_global: bool,
24
25 #[sea_orm(nullable)]
26 pub created_at: Option<DateTime>,
27
28 #[sea_orm(nullable)]
29 pub updated_at: Option<DateTime>,
30}
31
32impl ActiveModelBehavior for ActiveModel {}
34
35impl Entity {
37 pub fn find_by_number(number: i32) -> Select<Self> {
39 Self::find().filter(Column::Number.eq(number))
40 }
41
42 pub fn find_by_output(output: &str) -> Select<Self> {
44 Self::find().filter(Column::Output.eq(output))
45 }
46
47 pub fn find_global() -> Select<Self> {
49 Self::find().filter(Column::IsGlobal.eq(true))
50 }
51}