diff options
author | Harald Eilertsen <haraldei@anduin.net> | 2019-04-08 12:30:34 +0200 |
---|---|---|
committer | Harald Eilertsen <haraldei@anduin.net> | 2019-04-08 12:30:34 +0200 |
commit | 9c8b8a254a5223cd359df150279f78e644b58abb (patch) | |
tree | 047289dc2512e806431b8f854a03ac6b40e45f10 | |
parent | 99fbebe181ae53e376d43dbfb4f02e4a161a09a0 (diff) | |
download | ramaskrik-social-9c8b8a254a5223cd359df150279f78e644b58abb.tar.gz ramaskrik-social-9c8b8a254a5223cd359df150279f78e644b58abb.tar.bz2 ramaskrik-social-9c8b8a254a5223cd359df150279f78e644b58abb.zip |
Add models::film::by_title and models::room::by_name methods.
-rw-r--r-- | src/models/film.rs | 7 | ||||
-rw-r--r-- | src/models/room.rs | 7 |
2 files changed, 14 insertions, 0 deletions
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<Vec<Film>> { use crate::schema::films::dsl::*; films.load::<Film>(&**db) } + +pub fn by_title(ftitle: &str, db: &Connection) -> QueryResult<Film> { + use crate::schema::films::dsl::*; + films + .filter(title.eq(&ftitle)) + .get_result::<Film>(&**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<Vec<Room>> { use crate::schema::rooms::dsl::*; rooms.load::<Room>(&**db) } + +pub fn by_name(rname: &str, db: &Connection) -> QueryResult<Room> { + use crate::schema::rooms::dsl::*; + rooms + .filter(name.eq(&rname)) + .get_result::<Room>(&**db) +} |