post_archiver/
collection.rs1use 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#[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#[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")]
31mod definitions {
32 use crate::utils::macros::as_table;
33
34 use super::*;
35
36 as_table!(
37 "collections" => Collection {
38 id: "id",
39 name: "name",
40 thumb: "thumb",
41 source: "source",
42 }
43
44 "collection_posts" => CollectionPost {
45 collection: "collection",
46 post: "post",
47 }
48 );
49}