metis_core/dal/database/
models.rs1use diesel::prelude::*;
2use serde::{Deserialize, Serialize};
3
4#[derive(
5 Queryable,
6 Selectable,
7 Insertable,
8 AsChangeset,
9 QueryableByName,
10 Debug,
11 Clone,
12 Serialize,
13 Deserialize,
14)]
15#[diesel(table_name = crate::dal::database::schema::documents)]
16#[diesel(check_for_backend(diesel::sqlite::Sqlite))]
17pub struct Document {
18 pub filepath: String,
19 pub id: String,
20 pub title: String,
21 pub document_type: String,
22 pub created_at: f64,
23 pub updated_at: f64,
24 pub archived: bool,
25 pub exit_criteria_met: bool,
26 pub file_hash: String,
27 pub frontmatter_json: String,
28 pub content: Option<String>,
29 pub phase: String,
30}
31
32#[derive(Queryable, Selectable, Insertable, Debug, Clone, Serialize, Deserialize)]
33#[diesel(table_name = crate::dal::database::schema::document_relationships)]
34#[diesel(check_for_backend(diesel::sqlite::Sqlite))]
35pub struct DocumentRelationship {
36 pub child_id: String,
37 pub parent_id: String,
38 pub child_filepath: String,
39 pub parent_filepath: String,
40}
41
42#[derive(Queryable, Selectable, Insertable, Debug, Clone, Serialize, Deserialize)]
43#[diesel(table_name = crate::dal::database::schema::document_tags)]
44#[diesel(check_for_backend(diesel::sqlite::Sqlite))]
45pub struct DocumentTag {
46 pub document_filepath: String,
47 pub tag: String,
48}
49
50#[derive(Insertable)]
52#[diesel(table_name = crate::dal::database::schema::documents)]
53pub struct NewDocument {
54 pub filepath: String,
55 pub id: String,
56 pub title: String,
57 pub document_type: String,
58 pub created_at: f64,
59 pub updated_at: f64,
60 pub archived: bool,
61 pub exit_criteria_met: bool,
62 pub file_hash: String,
63 pub frontmatter_json: String,
64 pub content: Option<String>,
65 pub phase: String,
66}
67
68#[derive(Queryable, Selectable, Debug, Clone, Serialize, Deserialize)]
70#[diesel(table_name = crate::dal::database::schema::document_search)]
71#[diesel(check_for_backend(diesel::sqlite::Sqlite))]
72pub struct DocumentSearch {
73 pub rowid: i32,
74 pub document_filepath: String,
75 pub content: Option<String>,
76 pub title: Option<String>,
77 pub document_type: Option<String>,
78}
79
80#[derive(Insertable)]
81#[diesel(table_name = crate::dal::database::schema::document_search)]
82pub struct NewDocumentSearch {
83 pub document_filepath: String,
84 pub content: Option<String>,
85 pub title: Option<String>,
86 pub document_type: Option<String>,
87}