database entities
This commit is contained in:
parent
0be0c1ecbc
commit
c59d9eb34a
|
|
@ -0,0 +1,66 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
use mongodb::{
|
||||
bson::{DateTime, oid::ObjectId},
|
||||
Client,
|
||||
Database,
|
||||
error::Error,
|
||||
};
|
||||
|
||||
pub async fn get_database_client() -> Result<Database, Error> {
|
||||
Ok(Client::with_uri_str("mongodb:://localhost:27017").await?.database("dermy"))
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct Mole {
|
||||
#[serde(rename = "_id", skip_serializing_if = "Option::is_none")]
|
||||
id: Option<ObjectId>,
|
||||
#[serde(rename="_user_id")]
|
||||
user_id: ObjectId,
|
||||
#[serde(rename="_image_path")]
|
||||
image_path: Option<String>,
|
||||
location: Location,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub enum Location {
|
||||
FrontLocation(FrontLocation),
|
||||
LeftSideLocation(LeftSideLocation),
|
||||
RightSideLocation(RightSideLocation),
|
||||
BackLocation(BackLocation),
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub enum FrontLocation {} //TODO: Add front locations
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub enum LeftSideLocation {} //TODO: Add left side locations
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub enum RightSideLocation {} //TODO: Add right side locations
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub enum BackLocation {} //TODO: Add back locations
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct LogEntry {
|
||||
#[serde(rename = "_id", skip_serializing_if = "Option::is_none")]
|
||||
id: Option<ObjectId>,
|
||||
#[serde(rename = "_date_created")]
|
||||
date_created: DateTime,
|
||||
contents: String,
|
||||
#[serde(rename = "_mole_id")]
|
||||
mole_id: ObjectId
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct User {
|
||||
#[serde(rename = "_id", skip_serializing_if = "Option::is_none")]
|
||||
id: Option<ObjectId>,
|
||||
#[serde(rename="_auth")]
|
||||
auth: Auth,
|
||||
username: String,
|
||||
}
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct Auth {
|
||||
#[serde(rename = "_hash", skip_serializing_if = "String::is_empty")]
|
||||
hash: String,
|
||||
#[serde(rename = "_salt", skip_serializing_if = "String::is_empty")]
|
||||
salt: String,
|
||||
}
|
||||
Loading…
Reference in New Issue