feat(main): Add minimal thread listing example

This commit is contained in:
Vincent Ambo 2018-04-08 16:08:26 +02:00
parent f3f509d463
commit 5604d933e8
3 changed files with 11 additions and 3 deletions

View file

@ -19,8 +19,15 @@ fn connect_db() -> PgConnection {
fn main() {
use schema::threads::dsl::*;
use schema::posts::dsl::*;
use models::*;
let conn = connect_db();
let threads = threads.
let result: Vec<Thread> = threads
.load::<Thread>(&conn)
.expect("Error loading threads");
for thread in result {
println!("Subject: {}\nPosted: {}\n", thread.title, thread.posted);
println!("{}", thread.body);
}
}