╭ changed ────╮ │src/event.zig│ ╰─────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭──────────╮ │← previous│ ╰──────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────╮ │352 if (issue_data_maybe) |issue_data| { │ │353 const issue_cursor = try event_id_to_issue.putCursor(issue_key); │ │354 const issue = try DB.HashMap(.read_write).init(issue_cursor); │ │447 - try upsert(DB, repo_opts.hash, issue, EventData.Issue, issue_data); │ │355 + try upsert(DB, repo_opts.hash, issue, Issue, issue_data); │ │356 } else { │ │357 if (!try event_id_to_issue.remove(issue_key)) return error.EventNotFound;│ │358 } │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │371 try state.extra.moment.put(hash.hashInt(repo_opts.hash, "haxy-last-object-id"), .{ .bytes = last_object_id });│ │372 } │ │373 } │ │374 + │ │375 +// │ │376 +// reading from xitdb │ │377 +// │ │378 │ │379 +pub fn readBytes( │ │380 + comptime DB: type, │ │381 + comptime hash_kind: hash.HashKind, │ │382 + allocator: std.mem.Allocator, │ │383 + map: DB.HashMap(.read_only), │ │384 + field_name: []const u8, │ │385 +) ![]const u8 { │ │386 + const cursor = try map.getCursor(hash.hashInt(hash_kind, field_name)) orelse return error.NotFound; │ │387 + return try cursor.readBytesAlloc(allocator, null); │ │388 +} │ │389 + │ │390 +pub fn readBool( │ │391 + comptime DB: type, │ │392 + comptime hash_kind: hash.HashKind, │ │393 + map: DB.HashMap(.read_only), │ │394 + field_name: []const u8, │ │395 +) !bool { │ │396 + const cursor = try map.getCursor(hash.hashInt(hash_kind, field_name)) orelse return error.NotFound; │ │397 + var buffer: [5]u8 = undefined; │ │398 + const bytes = try cursor.readBytesObject(&buffer); │ │399 + const format_tag = bytes.format_tag orelse return error.InvalidFormatTag; │ │400 + if (!std.mem.eql(u8, &format_tag, "bl")) return error.InvalidFormatTag; │ │401 + if (std.mem.eql(u8, bytes.value, "true")) return true; │ │402 + if (std.mem.eql(u8, bytes.value, "false")) return false; │ │403 + return error.InvalidBool; │ │404 +} │ │405 + │ │406 +// │ │407 +// writing to xitdb │ │408 +// │ │409 + │ │410 fn upsert( │ │411 comptime DB: type, │ │412 comptime hash_kind: hash.HashKind, │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯