workspace reshape
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
pub mod prelude;
|
||||
pub mod stream_key;
|
||||
pub mod stream_session;
|
||||
@@ -0,0 +1,2 @@
|
||||
pub use super::stream_key::Entity as StreamKey;
|
||||
pub use super::stream_session::Entity as StreamSession;
|
||||
@@ -0,0 +1,28 @@
|
||||
use sea_orm::entity::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Serialize, Deserialize)]
|
||||
#[sea_orm(table_name = "stream_key")]
|
||||
pub struct Model {
|
||||
#[sea_orm(primary_key)]
|
||||
pub id: i32,
|
||||
#[sea_orm(unique)]
|
||||
pub key_value: String,
|
||||
pub label: String,
|
||||
pub is_active: bool,
|
||||
pub created_at: DateTimeUtc,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
pub enum Relation {
|
||||
#[sea_orm(has_many = "super::stream_session::Entity")]
|
||||
StreamSession,
|
||||
}
|
||||
|
||||
impl Related<super::stream_session::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
Relation::StreamSession.def()
|
||||
}
|
||||
}
|
||||
|
||||
impl ActiveModelBehavior for ActiveModel {}
|
||||
@@ -0,0 +1,30 @@
|
||||
use sea_orm::entity::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Serialize, Deserialize)]
|
||||
#[sea_orm(table_name = "stream_session")]
|
||||
pub struct Model {
|
||||
#[sea_orm(primary_key)]
|
||||
pub id: i32,
|
||||
pub stream_key_id: i32,
|
||||
pub started_at: DateTimeUtc,
|
||||
pub ended_at: Option<DateTimeUtc>,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
pub enum Relation {
|
||||
#[sea_orm(
|
||||
belongs_to = "super::stream_key::Entity",
|
||||
from = "Column::StreamKeyId",
|
||||
to = "super::stream_key::Column::Id"
|
||||
)]
|
||||
StreamKey,
|
||||
}
|
||||
|
||||
impl Related<super::stream_key::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
Relation::StreamKey.def()
|
||||
}
|
||||
}
|
||||
|
||||
impl ActiveModelBehavior for ActiveModel {}
|
||||
Reference in New Issue
Block a user