authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-10-21 20:31:44 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-10-21 20:31:44 -07:00
log3f56910018b4b6b067ff5ce2891fd858c3bc0ebf
treed3d7cd1093640a59b3728b446d57e3315c1f1dcd
parentcaaf5d24b97c2f016c5c44131cd5b8507d1d5082

add string alias


1 files changed, 4 insertions(+), 3 deletions(-)

src/sqlite3.zig+4-3
......@@ -1,4 +1,5 @@
11const std = @import("std");
2const string = []const u8;
23const sqlite = @import("sqlite");
34
45const Self = @This();
......@@ -24,8 +25,8 @@ pub fn close(self: *Self) void {
2425 self.db.deinit();
2526}
2627
27pub fn collect(self: *Self, alloc: *std.mem.Allocator, comptime T: type, comptime query: []const u8, args: anytype) ![]const T {
2828 var stmt = try self.db.prepare(query);
29pub fn collect(self: *Self, alloc: *std.mem.Allocator, comptime T: type, comptime query: string, args: anytype) ![]const T {
2930 defer stmt.deinit();
3031 var iter = try stmt.iteratorAlloc(T, alloc, args);
3132 var list = std.ArrayList(T).init(alloc);
......@@ -35,13 +36,13 @@ pub fn collect(self: *Self, alloc: *std.mem.Allocator, comptime T: type, comptim
3536 return list.toOwnedSlice();
3637}
3738
38pub fn exec(self: *Self, alloc: *std.mem.Allocator, comptime query: []const u8, args: anytype) !void {
39pub fn exec(self: *Self, alloc: *std.mem.Allocator, comptime query: string, args: anytype) !void {
3940 var stmt = try self.db.prepare(query);
4041 defer stmt.deinit();
4142 try stmt.execAlloc(.{ .allocator = alloc }, args);
4243}
4344
44pub fn first(self: *Self, alloc: *std.mem.Allocator, comptime T: type, comptime query: []const u8, args: anytype) !?T {
45pub fn first(self: *Self, alloc: *std.mem.Allocator, comptime T: type, comptime query: string, args: anytype) !?T {
4546 var stmt = try self.db.prepare(query);
4647 defer stmt.deinit();
4748 return try stmt.oneAlloc(T, alloc, .{}, args);