1use sea_orm::entity::prelude::*;
2
3use crate::db::FlagId;
4
5#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
6#[sea_orm(table_name = "feature_flags")]
7pub struct Model {
8 #[sea_orm(primary_key)]
9 pub id: FlagId,
10 pub flag: String,
11 pub enabled_for_all: bool,
12}
13
14#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
15pub enum Relation {
16 #[sea_orm(has_many = "super::user_feature::Entity")]
17 UserFeature,
18}
19
20impl Related<super::user_feature::Entity> for Entity {
21 fn to() -> RelationDef {
22 Relation::UserFeature.def()
23 }
24}
25
26impl ActiveModelBehavior for ActiveModel {}
27
28pub struct FlaggedUsers;
29
30impl Linked for FlaggedUsers {
31 type FromEntity = Entity;
32
33 type ToEntity = super::user::Entity;
34
35 fn link(&self) -> Vec<RelationDef> {
36 vec![
37 super::user_feature::Relation::Flag.def().rev(),
38 super::user_feature::Relation::User.def(),
39 ]
40 }
41}