mgtzm/src/main.zig

31 lines
682 B
Zig
Raw Normal View History

2022-10-20 11:23:15 +00:00
const std = @import("std");
const sqlite = @import("sqlite");
const Db = @import("Db.zig");
const Item = @import("Item.zig");
2022-10-21 16:58:44 +00:00
const Tag = @import("Tag.zig");
2022-10-20 11:23:15 +00:00
pub fn main() !void {
2022-10-21 16:58:44 +00:00
var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
defer arena.deinit();
const alloc = arena.allocator();
2022-10-20 11:23:15 +00:00
var db = try Db.init();
2022-10-21 16:58:44 +00:00
var tags = [2]Item.Tag{
.{ .name = "title", .value = "clean room" },
.{ .name = "task", .value = null },
2022-10-21 16:58:44 +00:00
};
var item = Item{ .id = null, .tags = &tags };
try item.persist(&db);
2022-10-21 18:38:16 +00:00
var jobj = item.toJson();
2022-10-21 16:58:44 +00:00
defer jobj.deinit();
2022-10-21 18:38:16 +00:00
2022-10-21 16:58:44 +00:00
_ = alloc;
2022-10-20 11:23:15 +00:00
2022-10-21 16:58:44 +00:00
std.debug.print("{s}\n", .{jobj.toString()});
2022-10-20 11:23:15 +00:00
}