import {Session} from "@/hooks/useSessions";
import client from "@/lib/mongodb";

const db = client.db(process.env.MONGODB_DB);

export const getSessionsByUser = async (id: string, limit?: number) =>
	await db
		.collection("sessions")
		.find<Session>({user: id})
		.limit(limit || 0)
		.toArray();
