Skip to content

Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.

561 B
Raw Blame
import "server-only";

import { prisma } from "@rallly/database";

import { getSession } from "@/lib/auth";

export async function getGuestPolls() {
  const session = await getSession();

  if (session?.user?.isGuest !== true) {
    return [];
  }

  const recentlyCreatedPolls = await prisma.poll.findMany({
    where: {
      userId: session.user.id,
      deleted: false,
    },
    select: {
      id: true,
      title: true,
      createdAt: true,
    },
    orderBy: {
      createdAt: "desc",
    },
    take: 3,
  });

  return recentlyCreatedPolls;
}