diff options
Diffstat (limited to 'src/db/models.rs')
| -rw-r--r-- | src/db/models.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/db/models.rs b/src/db/models.rs index d25b593..0708e7c 100644 --- a/src/db/models.rs +++ b/src/db/models.rs @@ -23,6 +23,10 @@ impl Meme { pub fn audio(&self, conn: &PgConnection) -> Option<Result<Audio>> {
self.audio_id.map(|x: i32| audio::table.filter(audio::id.eq(x)).first(conn).map_err(Error::from))
}
+
+ pub fn find(conn: &PgConnection, id: i32) -> Result<Meme> {
+ memes::table.find(id).get_result(conn).map_err(Error::from)
+ }
}
#[derive(Insertable, PartialEq, Debug)]
@@ -167,6 +171,12 @@ impl Metadata { .get_result::<Metadata>(conn)
.map_err(Error::from)
}
+
+ pub fn find(conn: &PgConnection, id: i32) -> Result<Metadata> {
+ metadata::table.find(id)
+ .get_result::<Metadata>(conn)
+ .map_err(Error::from)
+ }
}
#[derive(Insertable, PartialEq, Debug)]
|
