···55mod db;
66pub use db::*;
7788+/// For database stuff
99+pub use migration::{Migrator, MigratorTrait};
1010+pub use sea_orm::{Database, DatabaseConnection};
1111+812/// exported traits for the database
913pub use sea_orm::ActiveModelTrait;
1014pub use sea_orm::ActiveValue;
···1418/// Exporting this as DTO so we can newtype this in a later crate
1519/// and add additional functionality to it.
1620pub use migration::types::Priority as PriorityDTO;
2121+2222+pub use sea_orm::entity::prelude::DateTimeUtc;
17231824/// Color type, exporting as DTO because I might
1925/// want to newtype wrap this, might not have to, depending
···11+use std::path::PathBuf;
22+33+use dto::{NanoId, ZettelModelEx};
44+55+use crate::types::Tag;
66+77+/// A `Zettel` is a note about a single idea.
88+/// It can have many `Tag`s, just meaning it can fall under many
99+/// categories.
1010+#[expect(dead_code)]
1111+#[derive(Debug, Clone)]
1212+pub struct Zettel {
1313+ /// Should only be constructed from models.
1414+ _private: (),
1515+1616+ pub id: NanoId,
1717+ pub title: String,
1818+ /// a workspace-local file path, needs to be canonicalized before usage
1919+ pub file_path: PathBuf,
2020+ pub tags: Vec<Tag>,
2121+}
2222+2323+impl From<ZettelModelEx> for Zettel {
2424+ fn from(value: ZettelModelEx) -> Self {
2525+ assert!(
2626+ !value.tags.is_unloaded(),
2727+ "When fetching a Zettel from the database, we expect
2828+ to always have the tags loaded!!"
2929+ );
3030+3131+ Self {
3232+ _private: (),
3333+ id: value.nano_id,
3434+ title: value.title,
3535+ file_path: value.file_path.into(),
3636+ tags: value.tags.into_iter().map(Into::into).collect(),
3737+ }
3838+ }
3939+}