aboutsummaryrefslogtreecommitdiff
path: root/src/db/models.rs
diff options
context:
space:
mode:
authorNathan Perry <avaglir@gmail.com>2018-06-01 05:42:40 -0400
committerNathan Perry <avaglir@gmail.com>2018-06-01 05:42:40 -0400
commit413384896f66aeb2737f5f60433c2467d867fb36 (patch)
tree9fc8482e9d61d8d1038d791f46ef055d7cd7c0f7 /src/db/models.rs
parenta52eae2964e8e86bf3e587f17d607025f07efdbb (diff)
various command improvements
- support last_meme (report details about last meme played back) - update filter priority for meme search (check title match first)
Diffstat (limited to 'src/db/models.rs')
-rw-r--r--src/db/models.rs10
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)]