summaryrefslogtreecommitdiff
path: root/backend/src/Models
diff options
context:
space:
mode:
Diffstat (limited to 'backend/src/Models')
-rw-r--r--backend/src/Models/Description.zig36
1 files changed, 36 insertions, 0 deletions
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,
+};