about summary refs log tree commit diff
path: root/src/main.rs
blob: 2cb814a3434f8bef1d1953115b5318fe6b70cd5a (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
#[macro_use]
extern crate diesel;
extern crate chrono;

pub mod schema;
pub mod models;

use diesel::prelude::*;
use diesel::pg::PgConnection;
use std::env;

fn connect_db() -> PgConnection {
    let db_url = env::var("DATABASE_URL")
        .expect("DATABASE_URL must be set");

    PgConnection::establish(&db_url)
        .expect(&format!("Error connecting to {}", db_url))
}

fn main() {
    use schema::threads::dsl::*;
    use schema::posts::dsl::*;

    let conn = connect_db();
    let threads = threads.
}