2022-10-20 11:23:15 +00:00
|
|
|
const std = @import("std");
|
2022-10-21 16:58:44 +00:00
|
|
|
const sqlite = @import("sqlite");
|
|
|
|
|
2022-10-20 11:23:15 +00:00
|
|
|
const Db = @import("Db.zig");
|
|
|
|
const Item = @import("Item.zig");
|
|
|
|
|
2022-10-21 16:58:44 +00:00
|
|
|
const Self = @This();
|
|
|
|
|
2022-10-20 11:23:15 +00:00
|
|
|
name: []const u8,
|
2022-10-21 16:58:44 +00:00
|
|
|
|
|
|
|
pub fn persist(self: *Self, db: *sqlite.Db) !void {
|
|
|
|
///////////////////////////////////
|
|
|
|
// ** Insert item **
|
|
|
|
/////////////////////////////////
|
|
|
|
|
|
|
|
// TODO: Test if tag exists
|
|
|
|
if (true) {
|
|
|
|
const query = "INSERT INTO tag (name) VALUES (?);";
|
|
|
|
try db.exec(query, .{}, .{ .name = self.name });
|
|
|
|
}
|
|
|
|
|
|
|
|
std.debug.print("{any}", .{self});
|
|
|
|
}
|