Initial version of pools

This commit is contained in:
Bad Manners 2025-04-09 22:31:32 -03:00
parent fe7edb93ad
commit 2b6b1f30f4
21 changed files with 577 additions and 36 deletions

View file

@ -2,6 +2,7 @@
pub mod prelude;
pub mod samey_config;
pub mod samey_pool;
pub mod samey_pool_post;
pub mod samey_post;

View file

@ -1,5 +1,6 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.8
pub use super::samey_config::Entity as SameyConfig;
pub use super::samey_pool::Entity as SameyPool;
pub use super::samey_pool_post::Entity as SameyPoolPost;
pub use super::samey_post::Entity as SameyPost;

View file

@ -0,0 +1,18 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.8
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "samey_config")]
pub struct Model {
#[sea_orm(primary_key)]
pub id: i32,
#[sea_orm(unique)]
pub key: String,
pub data: Json,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {}
impl ActiveModelBehavior for ActiveModel {}

View file

@ -9,12 +9,22 @@ pub struct Model {
pub id: i32,
#[sea_orm(unique)]
pub name: String,
pub uploader_id: i32,
pub is_public: bool,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(has_many = "super::samey_pool_post::Entity")]
SameyPoolPost,
#[sea_orm(
belongs_to = "super::samey_user::Entity",
from = "Column::UploaderId",
to = "super::samey_user::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
SameyUser,
}
impl Related<super::samey_pool_post::Entity> for Entity {
@ -23,4 +33,10 @@ impl Related<super::samey_pool_post::Entity> for Entity {
}
}
impl Related<super::samey_user::Entity> for Entity {
fn to() -> RelationDef {
Relation::SameyUser.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View file

@ -15,10 +15,18 @@ pub struct Model {
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(has_many = "super::samey_pool::Entity")]
SameyPool,
#[sea_orm(has_many = "super::samey_post::Entity")]
SameyPost,
}
impl Related<super::samey_pool::Entity> for Entity {
fn to() -> RelationDef {
Relation::SameyPool.def()
}
}
impl Related<super::samey_post::Entity> for Entity {
fn to() -> RelationDef {
Relation::SameyPost.def()