init
This commit is contained in:
16
backend/src/actions.rs
Normal file
16
backend/src/actions.rs
Normal file
@@ -0,0 +1,16 @@
|
||||
extern crate diesel;
|
||||
|
||||
use backend::models::*;
|
||||
use diesel::prelude::*;
|
||||
use backend::*;
|
||||
|
||||
type DbError = Box<dyn std::error::Error + Send + Sync>;
|
||||
|
||||
pub fn list_pictures(conn: &PgConnection) -> Result<Vec<Picture>, DbError> {
|
||||
use self::schema::pictures::dsl::*;
|
||||
|
||||
Ok(pictures
|
||||
.limit(50)
|
||||
.order_by(created_at.desc())
|
||||
.load::<Picture>(conn)?)
|
||||
}
|
||||
Reference in New Issue
Block a user