This commit is contained in:
Johannes Heuel
2022-06-25 17:16:13 +02:00
commit 9449d992c0
33 changed files with 5100 additions and 0 deletions

16
backend/src/actions.rs Normal file
View 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)?)
}