From b5ce961b3ef30758f77e2487dc9b6ed2dd39de73 Mon Sep 17 00:00:00 2001 From: physcik Date: Mon, 27 Apr 2026 15:31:39 +0500 Subject: Weapon description support --- backend/src/Models/Description.zig | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 backend/src/Models/Description.zig (limited to 'backend/src/Models/Description.zig') diff --git a/backend/src/Models/Description.zig b/backend/src/Models/Description.zig new file mode 100644 index 0000000..a3774ab --- /dev/null +++ b/backend/src/Models/Description.zig @@ -0,0 +1,36 @@ +const std = @import("std"); +const pg = @import("pg"); + +// Is suitable for those tables: +// - RangedWeaponsDescriptions +pub const Description = struct { + Id: []const u8, + Language: []const u8, + Contents: []const u8, + + // Parses the db row and returns the result. You are expected to use the + // actual DB schema and use * as a fields selector + pub fn Map(row: *const pg.Row) !Description { + return Description { + .Id = try row.get([]const u8, 0), + .Language = try row.get([]const u8, 1), + .Contents = try row.get([]const u8, 2), + }; + } + + // Parses the db row and returns the result. You are expected to use the + // actual DB schema and use * as a fields selector + pub fn MapWithAlloc(allocator: std.mem.Allocator, row: *const pg.Row) !Description { + return Description { + .Id = try allocator.dupe(u8, try row.get([]const u8, 0)), + .Language = try allocator.dupe(u8, try row.get([]const u8, 1)), + .Contents = try allocator.dupe(u8, try row.get([]const u8, 2)), + }; + } + +}; + +pub const RequestBody = struct { + Language: []const u8, + Contents: []const u8, +}; -- cgit v1.3