From ae57359353cf31ff374a8932999742920878bf00 Mon Sep 17 00:00:00 2001 From: Ilion Beyst Date: Wed, 12 Oct 2022 22:52:15 +0200 Subject: upgrade to diesel 2.0 --- planetwars-server/src/db/maps.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 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 dffe4fd..8972461 100644 --- a/planetwars-server/src/db/maps.rs +++ b/planetwars-server/src/db/maps.rs @@ -3,7 +3,7 @@ use diesel::prelude::*; use crate::schema::maps; #[derive(Insertable)] -#[table_name = "maps"] +#[diesel(table_name = maps)] pub struct NewMap<'a> { pub name: &'a str, pub file_path: &'a str, @@ -16,20 +16,20 @@ pub struct Map { pub file_path: String, } -pub fn create_map(new_map: NewMap, conn: &PgConnection) -> QueryResult { +pub fn create_map(new_map: NewMap, conn: &mut PgConnection) -> QueryResult { diesel::insert_into(maps::table) .values(new_map) .get_result(conn) } -pub fn find_map(id: i32, conn: &PgConnection) -> QueryResult { +pub fn find_map(id: i32, conn: &mut PgConnection) -> QueryResult { maps::table.find(id).get_result(conn) } -pub fn find_map_by_name(name: &str, conn: &PgConnection) -> QueryResult { +pub fn find_map_by_name(name: &str, conn: &mut PgConnection) -> QueryResult { maps::table.filter(maps::name.eq(name)).first(conn) } -pub fn list_maps(conn: &PgConnection) -> QueryResult> { +pub fn list_maps(conn: &mut PgConnection) -> QueryResult> { maps::table.get_results(conn) } -- cgit v1.2.3