upend/src/database/inner/models.rs

51 lines
1.1 KiB
Rust
Raw Normal View History

use std::path::PathBuf;
2020-09-06 12:32:17 +02:00
use chrono::NaiveDateTime;
use serde::Serialize;
2020-08-27 00:11:50 +02:00
2020-09-07 21:21:54 +02:00
use super::schema::{data, files};
use crate::util::hash::Hash;
2020-09-07 21:21:54 +02:00
2021-12-04 16:45:06 +01:00
#[derive(Queryable, Serialize, Clone, Debug)]
2020-08-27 00:11:50 +02:00
pub struct File {
pub id: i32,
pub hash: Hash,
2020-08-27 00:11:50 +02:00
pub path: String,
pub valid: bool,
pub added: NaiveDateTime,
pub size: i64,
pub mtime: Option<NaiveDateTime>,
2020-08-27 00:11:50 +02:00
}
// todo - remove, try_from the actual model, impl queryable...
#[derive(Serialize, Clone, Debug)]
pub struct OutFile {
pub id: i32,
pub hash: Hash,
pub path: PathBuf,
pub valid: bool,
pub added: NaiveDateTime,
pub size: i64,
pub mtime: Option<NaiveDateTime>,
}
2020-08-27 00:11:50 +02:00
#[derive(Insertable, Debug)]
#[table_name = "files"]
pub struct NewFile {
pub hash: Vec<u8>,
2020-08-27 00:11:50 +02:00
pub path: String,
pub added: NaiveDateTime,
2020-08-27 00:11:50 +02:00
pub size: i64,
pub mtime: Option<NaiveDateTime>,
2020-08-27 00:11:50 +02:00
}
2020-09-07 21:21:54 +02:00
#[derive(Queryable, Insertable, Serialize, Debug)]
#[table_name = "data"]
pub struct Entry {
pub identity: Vec<u8>,
pub entity: Vec<u8>,
pub attribute: String,
2020-09-07 21:21:54 +02:00
pub value: String,
pub immutable: bool,
2020-09-07 21:21:54 +02:00
}