| ... | ... | @@ -1,4 +1,5 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const string = []const u8; |
| 2 | 3 | const sqlite = @import("sqlite"); |
| 3 | 4 | |
| 4 | 5 | const Self = @This(); |
| ... | ... | @@ -24,8 +25,8 @@ pub fn close(self: *Self) void { |
| 24 | 25 | self.db.deinit(); |
| 25 | 26 | } |
| 26 | 27 | |
| 27 | | pub fn collect(self: *Self, alloc: *std.mem.Allocator, comptime T: type, comptime query: []const u8, args: anytype) ![]const T { |
| 28 | 28 | var stmt = try self.db.prepare(query); |
| 29 | pub fn collect(self: *Self, alloc: *std.mem.Allocator, comptime T: type, comptime query: string, args: anytype) ![]const T { |
| 29 | 30 | defer stmt.deinit(); |
| 30 | 31 | var iter = try stmt.iteratorAlloc(T, alloc, args); |
| 31 | 32 | var list = std.ArrayList(T).init(alloc); |
| ... | ... | @@ -35,13 +36,13 @@ pub fn collect(self: *Self, alloc: *std.mem.Allocator, comptime T: type, comptim |
| 35 | 36 | return list.toOwnedSlice(); |
| 36 | 37 | } |
| 37 | 38 | |
| 38 | | pub fn exec(self: *Self, alloc: *std.mem.Allocator, comptime query: []const u8, args: anytype) !void { |
| 39 | pub fn exec(self: *Self, alloc: *std.mem.Allocator, comptime query: string, args: anytype) !void { |
| 39 | 40 | var stmt = try self.db.prepare(query); |
| 40 | 41 | defer stmt.deinit(); |
| 41 | 42 | try stmt.execAlloc(.{ .allocator = alloc }, args); |
| 42 | 43 | } |
| 43 | 44 | |
| 44 | | pub fn first(self: *Self, alloc: *std.mem.Allocator, comptime T: type, comptime query: []const u8, args: anytype) !?T { |
| 45 | pub fn first(self: *Self, alloc: *std.mem.Allocator, comptime T: type, comptime query: string, args: anytype) !?T { |
| 45 | 46 | var stmt = try self.db.prepare(query); |
| 46 | 47 | defer stmt.deinit(); |
| 47 | 48 | return try stmt.oneAlloc(T, alloc, .{}, args); |