From e26f13c8bba24e6f966888d5909f2803665c55a0 Mon Sep 17 00:00:00 2001 From: Ilion Beyst Date: Fri, 26 Aug 2022 19:21:30 +0200 Subject: add maps to matches api --- planetwars-server/src/db/maps.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'planetwars-server/src/db/maps.rs') 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 { maps::table.find(id).get_result(conn) } +pub fn find_map_by_name(name: &str, conn: &PgConnection) -> QueryResult { + maps::table.filter(maps::name.eq(name)).first(conn) +} + pub fn list_maps(conn: &PgConnection) -> QueryResult> { maps::table.get_results(conn) -} \ No newline at end of file +} -- cgit v1.2.3