From 9c8b8a254a5223cd359df150279f78e644b58abb Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Mon, 8 Apr 2019 12:30:34 +0200 Subject: Add models::film::by_title and models::room::by_name methods. --- src/models/film.rs | 7 +++++++ src/models/room.rs | 7 +++++++ 2 files changed, 14 insertions(+) (limited to 'src/models') diff --git a/src/models/film.rs b/src/models/film.rs index 3926dd1..8207e5d 100644 --- a/src/models/film.rs +++ b/src/models/film.rs @@ -41,3 +41,10 @@ pub fn get_all(db: &Connection) -> QueryResult> { use crate::schema::films::dsl::*; films.load::(&**db) } + +pub fn by_title(ftitle: &str, db: &Connection) -> QueryResult { + use crate::schema::films::dsl::*; + films + .filter(title.eq(&ftitle)) + .get_result::(&**db) +} diff --git a/src/models/room.rs b/src/models/room.rs index 2ec3c7f..6360c88 100644 --- a/src/models/room.rs +++ b/src/models/room.rs @@ -33,3 +33,10 @@ pub fn get_all(db: &Connection) -> QueryResult> { use crate::schema::rooms::dsl::*; rooms.load::(&**db) } + +pub fn by_name(rname: &str, db: &Connection) -> QueryResult { + use crate::schema::rooms::dsl::*; + rooms + .filter(name.eq(&rname)) + .get_result::(&**db) +} -- cgit v1.2.3