use std::hash::Hash;
use serde::{Deserialize, Serialize};
#[cfg(feature = "typescript")]
use ts_rs::TS;
use crate::{CollectionId, FileMetaId, PostId};
#[cfg_attr(feature = "typescript", derive(TS))]
#[cfg_attr(feature = "typescript", ts(export))]
#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq, Hash)]
pub struct Collection {
pub id: CollectionId,
pub name: String,
pub source: Option<String>,
pub thumb: Option<FileMetaId>,
}
#[cfg_attr(feature = "typescript", derive(TS))]
#[cfg_attr(feature = "typescript", ts(export))]
#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq, Hash)]
pub struct CollectionPost {
pub collection: CollectionId,
pub post: PostId,
}
#[cfg(feature = "utils")]
mod definitions {
use crate::utils::macros::as_table;
use super::*;
as_table!(
"collections" => Collection {
id: "id",
name: "name",
thumb: "thumb",
source: "source",
}
"collection_posts" => CollectionPost {
collection: "collection",
post: "post",
}
);
}