1use crate::db::UserId;
2use sea_orm::entity::prelude::*;
3
4#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
5#[sea_orm(table_name = "rate_buckets")]
6pub struct Model {
7 #[sea_orm(primary_key, auto_increment = false)]
8 pub user_id: UserId,
9 #[sea_orm(primary_key, auto_increment = false)]
10 pub rate_limit_name: String,
11 pub token_count: i32,
12 pub last_refill: DateTime,
13}
14
15#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
16pub enum Relation {
17 #[sea_orm(
18 belongs_to = "super::user::Entity",
19 from = "Column::UserId",
20 to = "super::user::Column::Id"
21 )]
22 User,
23}
24
25impl Related<super::user::Entity> for Entity {
26 fn to() -> RelationDef {
27 Relation::User.def()
28 }
29}
30
31impl ActiveModelBehavior for ActiveModel {}