blob: 6a8c95ae63072d3f883f089385b945564e4b901b [file] [log] [blame]
use super::*;
#[derive(PartialEq, Eq, Debug, Clone, Queryable, Identifiable, Associations)]
#[belongs_to(User)]
pub struct Post {
pub id: i32,
pub user_id: i32,
pub title: String,
pub body: Option<String>,
}
impl Post {
pub fn new(id: i32, user_id: i32, title: &str, body: Option<&str>) -> Self {
Post {
id: id,
user_id: user_id,
title: title.to_string(),
body: body.map(|s| s.to_string()),
}
}
}