-
-
Save stephanbuys/b0bf31af6d2fd091793100a17de8127b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
crate diesel_demo; | |
extern crate diesel; | |
use self::diesel_demo::*; | |
use self::diesel_demo::models::*; | |
use self::diesel::prelude::*; | |
fn main() { | |
use diesel_demo::schema::posts::dsl::*; | |
let connection = establish_connection(); | |
let results = posts.filter(published.eq(true)) | |
.limit(5) | |
.load::<Post>(&connection) | |
.expect("Error loading posts"); | |
println!("Displaying {} posts", results.len()); | |
for post in results { | |
println!("{}", post.title); | |
println!("----------\n"); | |
println!("{}", post.body); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment