Dimi
Dimi
Explore posts from servers
TTCTheo's Typesafe Cult
Created by Dimi on 9/16/2023 in #questions
Performance concern on Nextjs 13 layout files
Regarding the second question, I would like to know if the database would perform the same query again and again on every redirect that the admin does. Inside the isAdministrator function lies a prisma call something like this
export async function isAdministrator(): Promise<boolean> {
const session = await getServerSession(authOptions);
if (!session || !session.user?.email) return false;
const user = await prisma.user.findUnique({ where: { email: session.user.email } });
console.log(!!user && user.type === "admin")
return !!user && user.type === "admin";
}
export async function isAdministrator(): Promise<boolean> {
const session = await getServerSession(authOptions);
if (!session || !session.user?.email) return false;
const user = await prisma.user.findUnique({ where: { email: session.user.email } });
console.log(!!user && user.type === "admin")
return !!user && user.type === "admin";
}
2 replies