23 lines
711 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { usePrisma } from "./prisma";
/**
* Lädt nickname + avatar aus der profiles-Tabelle für mehrere User-IDs.
* Vollständig über Prisma kein Supabase Service Role benötigt.
*/
export async function getUsersMeta(
userIds: string[],
): Promise<Record<string, { nickname: string | null; avatar: string | null }>> {
if (userIds.length === 0) return {};
const db = usePrisma();
const profiles = await db.profile.findMany({
where: { id: { in: userIds } },
select: { id: true, nickname: true, username: true, avatar: true },
});
return Object.fromEntries(
profiles.map((p) => [
p.id,
{ nickname: p.nickname ?? p.username ?? null, avatar: p.avatar },
]),
);
}