buffer.rs

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