import { QueryCtx } from "../_generated/server";
import { Id } from "../_generated/dataModel";

export async function getCategoryOrThrow(
  ctx: QueryCtx,
  id: Id<"categories">,
) {
  const category = await ctx.db.get(id);
  if (!category) throw new Error("Category not found");
  return category;
}
