Finish database code

This commit is contained in:
Jai A
2020-05-15 22:00:47 -07:00
parent fee34ba257
commit 4b4889d5f2
10 changed files with 55 additions and 26 deletions

View File

@@ -4,7 +4,7 @@ use dotenv::dotenv;
use std::env;
pub fn connect() -> PgConnection{
dotenv.ok();
dotenv().ok();
let database_url = env::var("DATABASE_URL").expect("DATABASE_URL must be set!");
PgConnection::establish(&database_url).expect(&format!("Error connecting to {}", database_url))

View File

@@ -1,13 +1,11 @@
use serde::{Deserialize, Serialize};
use crate::schema::mods;
use chrono::NaiveDate;
#[derive(Queryable)]
pub struct Mod {
pub id: i32,
pub title: String,
pub description: String,
pub published: String,
pub published: NaiveDate,
pub author: String,
pub downloads: i32,
pub categories: Vec<String>,
@@ -17,12 +15,12 @@ pub struct Mod {
#[derive(Queryable)]
pub struct Version {
pub id: i32,
pub version_id: i32,
pub mod_id: i32,
pub title: String,
pub changelog_path: String,
pub files_path: Vec<String>,
pub date_published: String,
pub date_published: NaiveDate,
pub author: String,
pub downloads: i32,
pub dependencies: Vec<String>,