1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
use crate::lib_backend::schema::dir;
use crate::lib_backend::schema::entry;
use crate::lib_backend::schema::tag;
use crate::lib_backend::schema::dir_tags;
use crate::lib_backend::schema::entry_tags;
use chrono::{NaiveDateTime};

#[derive(Queryable)]
pub struct Dir {
	pub id: i32,
	pub name: String,
	pub loc: Option<i32>,
}

#[derive(Insertable)]
#[table_name = "dir"]
pub struct NewDir<'a> {
	pub name: &'a str,
	pub loc: Option<i32>,
}


#[derive(Queryable)]
pub struct Tag {
	pub id: i32,
	pub name: String,
}

#[derive(Insertable)]
#[table_name = "tag"]
pub struct NewTag<'a> {
	pub name: &'a str,
}

#[derive(Queryable)]
pub struct DirTag {
	pub dirid: i32,
	pub tagid: i32,
}

#[derive(Insertable)]
#[table_name = "dir_tags"]
pub struct NewDirTag {
	pub dirid: i32,
	pub tagid: i32,
}

#[derive(Queryable)]
#[derive(PartialEq)]
pub struct Entry {
	pub id: i32,
	pub name: String,
	pub data: Vec<u8>,
	pub type_: String,
	pub date_added: NaiveDateTime,
	pub date_last_modified: NaiveDateTime,
	pub loc: i32,
	pub label: Option<String>,
}

#[derive(Insertable)]
#[table_name = "entry"]
pub struct NewEntry<'a> {
	pub name: &'a str,
	pub data: &'a [u8],
	pub type_: &'a str,
	pub loc: i32,
	pub label: Option<&'a str>,
}

#[derive(Queryable)]
pub struct EntryTag {
	pub entryid: i32,
	pub tagid: i32,
}

#[derive(Insertable)]
#[table_name = "entry_tags"]
pub struct NewEntryTag {
	pub entryid: i32,
	pub tagid: i32,
}