diff --git a/plume-models/src/medias.rs b/plume-models/src/medias.rs index e3d33cc..c021f28 100644 --- a/plume-models/src/medias.rs +++ b/plume-models/src/medias.rs @@ -62,7 +62,14 @@ impl MediaCategory { impl Media { insert!(medias, NewMedia); get!(medias); - list_by!(medias, for_user, owner_id as i32); + + pub fn for_user(conn: &Connection, owner: i32) -> Result> { + medias::table + .filter(medias::owner_id.eq(owner)) + .order(medias::id.desc()) + .load::(conn) + .map_err(Error::from) + } pub fn list_all_medias(conn: &Connection) -> Result> { medias::table.load::(conn).map_err(Error::from) @@ -75,6 +82,7 @@ impl Media { ) -> Result> { medias::table .filter(medias::owner_id.eq(user.id)) + .order(medias::id.desc()) .offset(i64::from(min)) .limit(i64::from(max - min)) .load::(conn)