aboutsummaryrefslogtreecommitdiff
path: root/planetwars-server/src/db/maps.rs
diff options
context:
space:
mode:
authorIlion Beyst <ilion.beyst@gmail.com>2022-10-12 22:52:15 +0200
committerIlion Beyst <ilion.beyst@gmail.com>2022-10-12 22:52:15 +0200
commitae57359353cf31ff374a8932999742920878bf00 (patch)
tree0db27d394a2a61a5cc94e73014c82954829c1338 /planetwars-server/src/db/maps.rs
parented016773b112460ebbf0ff023b0915545229ed41 (diff)
downloadplanetwars.dev-ae57359353cf31ff374a8932999742920878bf00.tar.xz
planetwars.dev-ae57359353cf31ff374a8932999742920878bf00.zip
upgrade to diesel 2.0
Diffstat (limited to 'planetwars-server/src/db/maps.rs')
-rw-r--r--planetwars-server/src/db/maps.rs10
1 files changed, 5 insertions, 5 deletions
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<Map> {
+pub fn create_map(new_map: NewMap, conn: &mut PgConnection) -> QueryResult<Map> {
diesel::insert_into(maps::table)
.values(new_map)
.get_result(conn)
}
-pub fn find_map(id: i32, conn: &PgConnection) -> QueryResult<Map> {
+pub fn find_map(id: i32, conn: &mut PgConnection) -> QueryResult<Map> {
maps::table.find(id).get_result(conn)
}
-pub fn find_map_by_name(name: &str, conn: &PgConnection) -> QueryResult<Map> {
+pub fn find_map_by_name(name: &str, conn: &mut PgConnection) -> QueryResult<Map> {
maps::table.filter(maps::name.eq(name)).first(conn)
}
-pub fn list_maps(conn: &PgConnection) -> QueryResult<Vec<Map>> {
+pub fn list_maps(conn: &mut PgConnection) -> QueryResult<Vec<Map>> {
maps::table.get_results(conn)
}