╭ changed ────╮ │src/event.zig│ ╰─────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭───────────────────────────────────────────────╮ │ 5 const mrg = xit.merge; │ │ 6 const obj = xit.object; │ │ 7 const rf = xit.ref; │ │ 8 + │ │ 9 +pub const user = @import("event/user.zig");│ │10 │ │11 pub const event_id_size: usize = 32; │ │12 │ ╰───────────────────────────────────────────────╯ ╭────────────────────────────────╮ │13 pub const EventKind = enum {│ │14 + user, │ │15 issue, │ │16 }; │ │17 │ ╰────────────────────────────────╯ ╭────────────────────────────────────────────╮ │18 pub const EventData = union(EventKind) {│ │19 + user: struct { │ │20 + name: []const u8, │ │21 + email: []const u8, │ │22 + password_hash: []const u8, │ │23 + }, │ │24 issue: struct { │ │25 title: []const u8, │ │26 description: []const u8, │ ╰────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────╮ │35 kind: EventKind, │ │36 ) !EventData { │ │37 return switch (kind) { │ │38 + .user => .{ │ │39 + .user = .{ │ │40 + .name = try readBytes(DB, hash_kind, allocator, map, "name"), │ │41 + .email = try readBytes(DB, hash_kind, allocator, map, "email"), │ │42 + .password_hash = try readBytes(DB, hash_kind, allocator, map, "password_hash"),│ │43 + }, │ │44 + }, │ │45 .issue => .{ │ │46 .issue = .{ │ │47 .title = try readBytes(DB, hash_kind, allocator, map, "title"), │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │328 _ = try std.fmt.hexToBytes(&current_event_id, &event.id); │ │329 │ │330 switch (event.data) { │ │331 + .user => |data| { │ │332 + const event_id_to_user_cursor = try haxy_moment.putCursor(hash.hashInt(repo_opts.hash, "event-id->user")); │ │333 + const event_id_to_user = try DB.HashMap(.read_write).init(event_id_to_user_cursor); │ │334 + │ │335 + const user_cursor = try event_id_to_user.putCursor(hash.hashInt(repo_opts.hash, &current_event_id)); │ │336 + const user_map = try DB.HashMap(.read_write).init(user_cursor); │ │337 + │ │338 + try upsert(DB, repo_opts.hash, user_map, @TypeOf(data), data); │ │339 + }, │ │340 .issue => |data| { │ │341 const event_id_to_issue_cursor = try haxy_moment.putCursor(hash.hashInt(repo_opts.hash, "event-id->issue"));│ │342 const event_id_to_issue = try DB.HashMap(.read_write).init(event_id_to_issue_cursor); │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯