Parent and child posts

This commit is contained in:
Bad Manners 2025-04-08 23:10:10 -03:00
parent 04f888c323
commit 54379b98e0
16 changed files with 334 additions and 58 deletions

View file

@ -2,6 +2,8 @@
pub mod prelude;
pub mod samey_pool;
pub mod samey_pool_post;
pub mod samey_post;
pub mod samey_post_source;
pub mod samey_session;

View file

@ -1,5 +1,7 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.8
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;
pub use super::samey_post_source::Entity as SameyPostSource;
pub use super::samey_session::Entity as SameySession;

View file

@ -0,0 +1,26 @@
//! `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_pool")]
pub struct Model {
#[sea_orm(primary_key)]
pub id: i32,
#[sea_orm(unique)]
pub name: String,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(has_many = "super::samey_pool_post::Entity")]
SameyPoolPost,
}
impl Related<super::samey_pool_post::Entity> for Entity {
fn to() -> RelationDef {
Relation::SameyPoolPost.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View file

@ -0,0 +1,48 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.8
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
#[sea_orm(table_name = "samey_pool_post")]
pub struct Model {
#[sea_orm(primary_key)]
pub id: i32,
pub pool_id: i32,
pub post_id: i32,
#[sea_orm(column_type = "Float")]
pub position: f32,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::samey_pool::Entity",
from = "Column::PoolId",
to = "super::samey_pool::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
SameyPool,
#[sea_orm(
belongs_to = "super::samey_post::Entity",
from = "Column::PostId",
to = "super::samey_post::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
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()
}
}
impl ActiveModelBehavior for ActiveModel {}

View file

@ -24,6 +24,8 @@ pub struct Model {
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(has_many = "super::samey_pool_post::Entity")]
SameyPoolPost,
#[sea_orm(
belongs_to = "Entity",
from = "Column::ParentId",
@ -46,6 +48,12 @@ pub enum Relation {
SameyUser,
}
impl Related<super::samey_pool_post::Entity> for Entity {
fn to() -> RelationDef {
Relation::SameyPoolPost.def()
}
}
impl Related<super::samey_post_source::Entity> for Entity {
fn to() -> RelationDef {
Relation::SameyPostSource.def()

View file

@ -7,9 +7,10 @@ use sea_orm::entity::prelude::*;
pub struct Model {
#[sea_orm(primary_key)]
pub id: i32,
#[sea_orm(unique)]
pub session_id: String,
pub data: Json,
pub expiry_date: String,
pub expiry_date: i64,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]