about summary refs log tree commit diff
path: root/src/main.rs
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@gmail.com>2018-04-08T14·08+0200
committerVincent Ambo <tazjin@gmail.com>2018-04-08T14·08+0200
commit5604d933e89f9020299f59d927d73f2cd12b4134 (patch)
treed68788bf6b622884cf88db292103102222155de8 /src/main.rs
parentf3f509d4631eb7f968894f1f5445071164b2e515 (diff)
feat(main): Add minimal thread listing example
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs
index 2cb814a3434f..6e98fe8b1d73 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -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);
+    }
 }