╭ changed ─────────╮ │src/event/User.zig│ ╰──────────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │191 arena: *std.heap.ArenaAllocator, │ │192 email: []const u8, │ │193 ) !?Public { │ │194 + const user_id = (try readIdByEmail(DB, hash_kind, haxy_moment, email)) orelse return null; │ │195 + const user_map = try userMap(DB, hash_kind, haxy_moment, &user_id) orelse return null; │ │196 + const record = try evt.read(struct { event: Public }, DB, hash_kind, arena, user_map); │ │197 + return record.event; │ │198 +} │ │199 + │ │200 +// a user's id via the email->user-id index │ │201 +pub fn readIdByEmail( │ │202 + comptime DB: type, │ │203 + comptime hash_kind: hash.HashKind, │ │204 + haxy_moment: DB.HashMap(.read_only), │ │205 + email: []const u8, │ │206 +) !?[evt.event_id_size]u8 { │ │207 const email_to_user_id_cursor = (try haxy_moment.getCursor(hash.hashInt(hash_kind, email_to_user_id_key))) orelse return null;│ │208 const email_to_user_id = try DB.HashMap(.read_only).init(email_to_user_id_cursor); │ │209 const user_id_cursor = (try email_to_user_id.getCursor(hash.hashInt(hash_kind, email))) orelse return null; │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────╮ │210 var user_id: [evt.event_id_size]u8 = undefined; │ │211 _ = try user_id_cursor.readBytes(&user_id); │ │199 - const user_map = try userMap(DB, hash_kind, haxy_moment, &user_id) orelse return null;│ │200 - const record = try evt.read(struct { event: Public }, DB, hash_kind, arena, user_map);│ │201 - return record.event; │ │212 + return user_id; │ │213 } │ │214 │ │215 // a user's id via the name->user-id index │ ╰───────────────────────────────────────────────────────────────────────────────────────────────╯