12 lines
300 B
TypeScript
12 lines
300 B
TypeScript
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();
|