summaryrefslogtreecommitdiff
path: root/backend/src/Database/RangedWeaponsAccessLayer.zig
blob: a99d1c1289aa02e19ae470a4a06f053dcd3a44ff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// You are not supposed to include this file. To access this you should use
// Connection.RangedWeapons. 

const conn = @import("Connection.zig");
const std = @import("std");
const pg = @import("pg");
const model = @import("../Models/RangedWeapon.zig");

pub fn GetAll(alloc: std.mem.Allocator) !std.ArrayList(model.RangedWeaponType) {
    const query = "SELECT * FROM RangedWeapons";
    var result = try conn.pool.query(query, .{});
    defer _ = result.deinit();

    var outp: std.ArrayList(model.RangedWeaponType) = .empty;
    while (try result.next()) |row| {
        const newRW = try model.RangedWeaponType.Map(&row);
        try outp.append(alloc, newRW);
    }
    return outp;
}