about summary refs log tree commit diff
path: root/fun/tvldb/src/models.rs
blob: 721efbbb2e6132387d9e7f9a274fb9210e90c9f0 (plain) (blame)
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
use crate::schema::{entries, keywords};
use chrono::NaiveDateTime;

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

#[derive(Queryable)]
pub struct Entry {
    pub id: i32,
    pub keyword_id: i32,
    pub idx: i32,
    pub text: String,
    pub creation_ts: NaiveDateTime,
    pub created_by: String,
}

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

#[derive(Insertable)]
#[table_name = "entries"]
pub struct NewEntry<'a> {
    pub keyword_id: i32,
    pub idx: i32,
    pub text: &'a str,
    pub creation_ts: NaiveDateTime,
    pub created_by: &'a str,
}