╭ changed ────────────╮ │src/event/Comment.zig│ ╰─────────────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │118 const replies_cursor = try parent_id_to_comment_id_set.putCursor(hash.hashInt(hash_kind, &record_to_write.event.parent_id));│ │119 const replies = try DB.SortedSet(.read_write).init(replies_cursor); │ │120 try replies.put(&thread_order_key); │ │121 +} │ │122 + │ │123 +// read a comment by event id, or null if the id isn't a known comment. field │ │124 +// byte slices are allocated in `arena`. │ │125 +pub fn readById( │ │126 + comptime DB: type, │ │127 + comptime hash_kind: hash.HashKind, │ │128 + haxy_moment: DB.HashMap(.read_only), │ │129 + arena: *std.heap.ArenaAllocator, │ │130 + comment_id: []const u8, │ │131 +) !?Record { │ │132 + const records_cursor = try haxy_moment.getCursor(hash.hashInt(hash_kind, record_map_key)) orelse return null; │ │133 + const records = try DB.HashMap(.read_only).init(records_cursor); │ │134 + const record_cursor = try records.getCursor(hash.hashInt(hash_kind, comment_id)) orelse return null; │ │135 + const record_map = try DB.HashMap(.read_only).init(record_cursor); │ │136 + return try evt.read(Record, DB, hash_kind, arena, record_map); │ │137 } │ │138 │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯