2018-04-08 15:49:19 +02:00
|
|
|
use chrono::prelude::{DateTime, Utc};
|
2018-04-08 18:27:15 +02:00
|
|
|
use schema::{threads, posts};
|
2018-04-08 15:49:19 +02:00
|
|
|
|
2018-04-08 18:27:15 +02:00
|
|
|
#[derive(Identifiable, Queryable, Serialize)]
|
2018-04-08 15:49:19 +02:00
|
|
|
pub struct Thread {
|
|
|
|
pub id: i32,
|
|
|
|
pub title: String,
|
|
|
|
pub body: String,
|
|
|
|
pub posted: DateTime<Utc>,
|
|
|
|
}
|
|
|
|
|
2018-04-08 18:27:15 +02:00
|
|
|
#[derive(Identifiable, Queryable, Serialize, Associations)]
|
|
|
|
#[belongs_to(Thread)]
|
2018-04-08 15:49:19 +02:00
|
|
|
pub struct Post {
|
|
|
|
pub id: i32,
|
2018-04-08 18:27:15 +02:00
|
|
|
pub thread_id: i32,
|
2018-04-08 15:49:19 +02:00
|
|
|
pub body: String,
|
|
|
|
pub posted: DateTime<Utc>,
|
|
|
|
}
|
2018-04-08 19:41:28 +02:00
|
|
|
|
2018-04-08 20:01:32 +02:00
|
|
|
#[derive(Deserialize, Insertable)]
|
2018-04-08 19:41:28 +02:00
|
|
|
#[table_name="threads"]
|
|
|
|
pub struct NewThread {
|
|
|
|
pub title: String,
|
|
|
|
pub body: String,
|
|
|
|
}
|