| ... | ... | @@ -32,11 +32,12 @@ fn prepare(self: *Self, comptime query: string) !sqlite.StatementType(.{}, query |
| 32 | 32 | }; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | | pub fn collect(self: *Self, alloc: std.mem.Allocator, comptime T: type, comptime query: string, args: anytype) ![]const T { |
| 35 | pub fn collect(self: *Self, alloc: std.mem.Allocator, comptime T: type, comptime query: string, args: anytype) ![]T { |
| 36 | 36 | var stmt = try self.prepare(query); |
| 37 | 37 | defer stmt.deinit(); |
| 38 | 38 | var iter = try stmt.iteratorAlloc(T, alloc, args); |
| 39 | 39 | var list = std.ArrayList(T).init(alloc); |
| 40 | errdefer list.deinit(); |
| 40 | 41 | while (try iter.nextAlloc(alloc, .{})) |row| { |
| 41 | 42 | try list.append(row); |
| 42 | 43 | } |