aboutsummaryrefslogtreecommitdiffstats
path: root/src/controllers
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2019-04-08 15:55:14 +0200
committerHarald Eilertsen <haraldei@anduin.net>2019-04-08 15:55:14 +0200
commitad0e585abed7a189b6117e9187c9afff809d1414 (patch)
treed1e80624e0f87882e90c0fe87a99a817e7edc61d /src/controllers
parent5ab5f490bc7199709fbc03d51bf6131e92269fdc (diff)
downloadramaskrik-social-ad0e585abed7a189b6117e9187c9afff809d1414.tar.gz
ramaskrik-social-ad0e585abed7a189b6117e9187c9afff809d1414.tar.bz2
ramaskrik-social-ad0e585abed7a189b6117e9187c9afff809d1414.zip
Move functions to query/modify db to connection object.
Makes tha API a bit nicer by asking the database rather than passing the database on to each model. Reserve models for method/functions that work on the model structs themselves.
Diffstat (limited to 'src/controllers')
-rw-r--r--src/controllers/film.rs2
-rw-r--r--src/controllers/room.rs2
-rw-r--r--src/controllers/screening.rs4
3 files changed, 4 insertions, 4 deletions
diff --git a/src/controllers/film.rs b/src/controllers/film.rs
index f4bcd03..e61a543 100644
--- a/src/controllers/film.rs
+++ b/src/controllers/film.rs
@@ -28,5 +28,5 @@ use rocket_contrib::{
#[get("/")]
pub fn get_films(db: db::Connection) -> Json<Vec<film::Film>> {
- Json(film::get_all(&db).unwrap())
+ Json(db.get_films().unwrap())
}
diff --git a/src/controllers/room.rs b/src/controllers/room.rs
index df77414..a203454 100644
--- a/src/controllers/room.rs
+++ b/src/controllers/room.rs
@@ -28,5 +28,5 @@ use rocket_contrib::{
#[get("/")]
pub fn get_rooms(db: db::Connection) -> Json<Vec<room::Room>> {
- Json(room::get_all(&db).unwrap())
+ Json(db.get_rooms().unwrap())
}
diff --git a/src/controllers/screening.rs b/src/controllers/screening.rs
index d060eb7..622e9cb 100644
--- a/src/controllers/screening.rs
+++ b/src/controllers/screening.rs
@@ -18,7 +18,7 @@
use crate::{
db,
- models::{screening::{self, Screening}, film::Film, room::Room},
+ models::{screening::Screening, film::Film, room::Room},
};
use rocket::get;
@@ -28,5 +28,5 @@ use rocket_contrib::{
#[get("/")]
pub fn get_screenings(db: db::Connection) -> Json<Vec<(Screening, Option<Film>, Option<Room>)>> {
- Json(screening::get_all(&db).unwrap())
+ Json(db.get_screenings().unwrap())
}