diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main.rs | 11 | ||||
-rw-r--r-- | src/models.rs | 1 |
2 files changed, 10 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); + } } diff --git a/src/models.rs b/src/models.rs index a7ed8a91df03..e502891305a2 100644 --- a/src/models.rs +++ b/src/models.rs @@ -8,6 +8,7 @@ pub struct Thread { pub posted: DateTime<Utc>, } +#[derive(Queryable)] pub struct Post { pub id: i32, pub thread: i32, |