observed_buffer_edits.rs

 1use crate::db::{BufferId, UserId};
 2use sea_orm::entity::prelude::*;
 3
 4#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)]
 5#[sea_orm(table_name = "observed_buffer_edits")]
 6pub struct Model {
 7    #[sea_orm(primary_key)]
 8    pub user_id: UserId,
 9    pub buffer_id: BufferId,
10    pub epoch: i32,
11    pub lamport_timestamp: i32,
12    pub replica_id: i32,
13}
14
15#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
16pub enum Relation {
17    #[sea_orm(
18        belongs_to = "super::buffer::Entity",
19        from = "Column::BufferId",
20        to = "super::buffer::Column::Id"
21    )]
22    Buffer,
23    #[sea_orm(
24        belongs_to = "super::user::Entity",
25        from = "Column::UserId",
26        to = "super::user::Column::Id"
27    )]
28    User,
29}
30
31impl Related<super::buffer::Entity> for Entity {
32    fn to() -> RelationDef {
33        Relation::Buffer.def()
34    }
35}
36
37impl Related<super::user::Entity> for Entity {
38    fn to() -> RelationDef {
39        Relation::User.def()
40    }
41}
42
43impl ActiveModelBehavior for ActiveModel {}