post_archiver/
collection.rs

1use std::hash::Hash;
2
3use serde::{Deserialize, Serialize};
4
5#[cfg(feature = "typescript")]
6use ts_rs::TS;
7
8use crate::{CollectionId, FileMetaId, PostId};
9
10/// A content creator or contributor in the system
11#[cfg_attr(feature = "typescript", derive(TS))]
12#[cfg_attr(feature = "typescript", ts(export))]
13#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq, Hash)]
14pub struct Collection {
15    pub id: CollectionId,
16    pub name: String,
17    pub source: Option<String>,
18    pub thumb: Option<FileMetaId>,
19}
20
21/// Association type that creates a many-to-many relationship between collections and posts
22#[cfg_attr(feature = "typescript", derive(TS))]
23#[cfg_attr(feature = "typescript", ts(export))]
24#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq, Hash)]
25pub struct CollectionPost {
26    pub collection: CollectionId,
27    pub post: PostId,
28}
29
30#[cfg(feature = "utils")]
31crate::utils::macros::as_table! {
32    Collection {
33        id: "id",
34        name: "name",
35        thumb: "thumb",
36        source: "source",
37    }
38
39    CollectionPost {
40        collection: "collection",
41        post: "post",
42    }
43}