init
This commit is contained in:
@@ -20,6 +20,8 @@ pub struct Model {
|
||||
pub sha256: Option<String>,
|
||||
pub created_at: DateTimeUtc,
|
||||
pub updated_at: DateTimeUtc,
|
||||
#[sea_orm(has_many)]
|
||||
pub reactions: HasMany<super::message_reaction::Entity>,
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
|
||||
@@ -19,6 +19,8 @@ pub struct Model {
|
||||
pub reply_to_id: Option<Uuid>,
|
||||
#[sea_orm(has_many)]
|
||||
pub attachments: HasMany<super::attachment::Entity>,
|
||||
#[sea_orm(has_many)]
|
||||
pub reactions: HasMany<super::message_reaction::Entity>,
|
||||
#[sea_orm(
|
||||
belongs_to,
|
||||
from = "channel_id",
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
use sea_orm::Set;
|
||||
use sea_orm::entity::prelude::*;
|
||||
use sea_orm::prelude::async_trait::async_trait;
|
||||
|
||||
#[sea_orm::model]
|
||||
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
|
||||
#[sea_orm(table_name = "message_reaction")]
|
||||
pub struct Model {
|
||||
#[sea_orm(primary_key, auto_increment = false)]
|
||||
pub id: Uuid,
|
||||
pub message_id: Uuid,
|
||||
pub user_id: Uuid,
|
||||
pub emoji_id: Uuid,
|
||||
pub skin_tone: i32,
|
||||
pub created_at: DateTimeUtc,
|
||||
#[sea_orm(belongs_to, from = "message_id", to = "id", on_delete = "Cascade")]
|
||||
pub message: HasOne<super::message::Entity>,
|
||||
#[sea_orm(belongs_to, from = "user_id", to = "id", on_delete = "Cascade")]
|
||||
pub user: HasOne<super::user::Entity>,
|
||||
#[sea_orm(belongs_to, from = "emoji_id", to = "id", on_delete = "Cascade")]
|
||||
pub emoji: HasOne<super::emoji::Entity>,
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl ActiveModelBehavior for ActiveModel {
|
||||
fn new() -> Self {
|
||||
Self {
|
||||
id: Set(Uuid::now_v7()),
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@ pub mod channel_user_read_state;
|
||||
pub mod computed_permission;
|
||||
pub mod emoji;
|
||||
pub mod message;
|
||||
pub mod message_reaction;
|
||||
pub mod role;
|
||||
pub mod role_user;
|
||||
pub mod server;
|
||||
|
||||
@@ -8,6 +8,7 @@ pub use super::channel_user_read_state::Entity as ChannelUserReadState;
|
||||
pub use super::computed_permission::Entity as ComputedPermission;
|
||||
pub use super::emoji::Entity as Emoji;
|
||||
pub use super::message::Entity as Message;
|
||||
pub use super::message_reaction::Entity as MessageReaction;
|
||||
pub use super::role::Entity as Group;
|
||||
pub use super::role_user::Entity as GroupMember;
|
||||
pub use super::server::Entity as Server;
|
||||
|
||||
@@ -23,6 +23,8 @@ pub struct Model {
|
||||
#[sea_orm(has_many)]
|
||||
pub messages: HasMany<super::message::Entity>,
|
||||
#[sea_orm(has_many)]
|
||||
pub message_reactions: HasMany<super::message_reaction::Entity>,
|
||||
#[sea_orm(has_many)]
|
||||
pub server_users: HasMany<super::server_user::Entity>,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user