╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ User.zig ─────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
239 const user_cursor = try event_id_to_user.getCursor(hash.hashInt(hash_kind, user_id)) orelse return null; 240 return try DB.HashMap(.read_only).init(user_cursor); 241 } 242 243 // read a user by name from the admin event store, or null if the admin repo or 244 // the user doesn't exist. field byte slices are allocated in `arena`. 245 pub fn readByName( 246 io: std.Io, 247 allocator: std.mem.Allocator, 248 admin_repo_path: []const u8, 249 arena: *std.heap.ArenaAllocator, 250 name: []const u8, 251 ) !?Record { 252 var repo = rp.Repo(.xit, evt.admin_repo_opts).open(io, allocator, .{ .path = admin_repo_path }) catch |err| switch (err) { 253 error.RepoNotFound => return null, 254 else => |e| return e, 255 }; 256 defer repo.deinit(io, allocator); 257 258 const moment = try evt.currentMoment(evt.admin_repo_opts, &repo); 259 260 const user_id = try readIdByName(evt.AdminDB, evt.admin_repo_opts.hash, moment, name) orelse return null; 261 262 return try readById(evt.AdminDB, evt.admin_repo_opts.hash, moment, arena, &user_id); 263 } 264