aboutsummaryrefslogtreecommitdiff
path: root/planetwars-server/src/db
diff options
context:
space:
mode:
Diffstat (limited to 'planetwars-server/src/db')
-rw-r--r--planetwars-server/src/db/maps.rs8
-rw-r--r--planetwars-server/src/db/matches.rs1
2 files changed, 7 insertions, 2 deletions
diff --git a/planetwars-server/src/db/maps.rs b/planetwars-server/src/db/maps.rs
index c9f50a0..dffe4fd 100644
--- a/planetwars-server/src/db/maps.rs
+++ b/planetwars-server/src/db/maps.rs
@@ -1,4 +1,4 @@
-use diesel::{PgConnection, QueryDsl, QueryResult, RunQueryDsl};
+use diesel::prelude::*;
use crate::schema::maps;
@@ -26,6 +26,10 @@ pub fn find_map(id: i32, conn: &PgConnection) -> QueryResult<Map> {
maps::table.find(id).get_result(conn)
}
+pub fn find_map_by_name(name: &str, conn: &PgConnection) -> QueryResult<Map> {
+ maps::table.filter(maps::name.eq(name)).first(conn)
+}
+
pub fn list_maps(conn: &PgConnection) -> QueryResult<Vec<Map>> {
maps::table.get_results(conn)
-} \ No newline at end of file
+}
diff --git a/planetwars-server/src/db/matches.rs b/planetwars-server/src/db/matches.rs
index e2db0c1..86939be 100644
--- a/planetwars-server/src/db/matches.rs
+++ b/planetwars-server/src/db/matches.rs
@@ -21,6 +21,7 @@ pub struct NewMatch<'a> {
pub state: MatchState,
pub log_path: &'a str,
pub is_public: bool,
+ pub map_id: Option<i32>,
}
#[derive(Insertable)]