feat(models/schema): Map up posts & threads table

This commit is contained in:
Vincent Ambo 2018-04-08 15:49:19 +02:00
parent 042eb88fd7
commit 72691c8d63
2 changed files with 40 additions and 0 deletions

16
src/models.rs Normal file
View file

@ -0,0 +1,16 @@
use chrono::prelude::{DateTime, Utc};
#[derive(Queryable)]
pub struct Thread {
pub id: i32,
pub title: String,
pub body: String,
pub posted: DateTime<Utc>,
}
pub struct Post {
pub id: i32,
pub thread: i32,
pub body: String,
pub posted: DateTime<Utc>,
}

24
src/schema.rs Normal file
View file

@ -0,0 +1,24 @@
table! {
posts (id) {
id -> Int4,
thread -> Int4,
body -> Text,
posted -> Timestamptz,
}
}
table! {
threads (id) {
id -> Int4,
title -> Varchar,
body -> Text,
posted -> Timestamptz,
}
}
joinable!(posts -> threads (thread));
allow_tables_to_appear_in_same_query!(
posts,
threads,
);