Fixed getting timestamp.

This commit is contained in:
BurnyLlama 2022-11-06 12:14:04 +01:00
parent 40e8974d6b
commit 7717e98ae9
3 changed files with 5 additions and 2 deletions

View File

@ -8,4 +8,5 @@ edition = "2021"
[dependencies] [dependencies]
rocket = { version = "0.5.0-rc.2", features = ["json"] } rocket = { version = "0.5.0-rc.2", features = ["json"] }
mysql = "22.2.0" mysql = "22.2.0"
mysql_common = { version = "0.28.2", features = ["chrono"] }
dotenv = "0.15.0" dotenv = "0.15.0"

View File

@ -3,6 +3,7 @@ use std::result::Result;
use std::error::Error; use std::error::Error;
use mysql::*; use mysql::*;
use mysql::prelude::*; use mysql::prelude::*;
use crate::types; use crate::types;
pub fn get_maps() -> Result<Vec<types::Map>, Box<dyn Error>> { pub fn get_maps() -> Result<Vec<types::Map>, Box<dyn Error>> {
@ -37,7 +38,7 @@ pub fn get_map_by_name(name: &str) -> Result<Option<types::Map>, Box<dyn Error>>
pub fn create_pool() -> Result<Pool, Box<dyn Error>> { fn create_pool() -> Result<Pool, Box<dyn Error>> {
let url = env::var("DB_URI")?; let url = env::var("DB_URI")?;
let pool = Pool::new(url.as_str())?; let pool = Pool::new(url.as_str())?;
Ok(pool) Ok(pool)

View File

@ -1,3 +1,4 @@
use mysql_common::chrono::NaiveDateTime;
use rocket::serde::{Serialize, Deserialize}; use rocket::serde::{Serialize, Deserialize};
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] #[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
@ -8,5 +9,5 @@ pub struct Map {
pub points: i8, pub points: i8,
pub stars: i8, pub stars: i8,
pub mapper: String, pub mapper: String,
pub timestamp: String, pub timestamp: NaiveDateTime,
} }