import { query } from "./_generated/server";
import { v } from "convex/values";

export const get = query({
  args: { slug: v.string() },
  handler: async (ctx, { slug }) => {
    const candidates = await ctx.db
      .query("games")
      .withIndex("by_slug", (q) => q.eq("slug", slug))
      .collect();
    return candidates[0] ?? null;
  },
});
