forked from diesel-rs/diesel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomment.rs
More file actions
31 lines (28 loc) · 800 Bytes
/
Copy pathcomment.rs
File metadata and controls
31 lines (28 loc) · 800 Bytes
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
27
28
29
30
31
use chrono::NaiveDateTime;
use diesel::prelude::*;
use crate::auth::User;
use crate::post::Post;
use crate::schema::comments;
#[derive(Queryable, Identifiable, Associations)]
#[diesel(belongs_to(User))]
#[diesel(belongs_to(Post))]
pub struct Comment {
pub id: i32,
pub user_id: i32,
pub post_id: i32,
pub body: String,
pub created_at: NaiveDateTime,
pub updated_at: NaiveDateTime,
}
pub fn render(comments_and_post_title: &[(Comment, String)]) {
for &(ref comment, ref post_title) in comments_and_post_title {
println!("On post {}", post_title);
println!(
"At {} (id: {})",
comment.updated_at.format("%F %T"),
comment.id
);
println!("{}", comment.body);
println!("===============\n");
}
}