aboutsummaryrefslogtreecommitdiffstats
path: root/src/models
diff options
context:
space:
mode:
Diffstat (limited to 'src/models')
-rw-r--r--src/models/film.rs7
-rw-r--r--src/models/room.rs7
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)
+}