el.xwx.moe/lib/api/hasAccessToCollection.ts
2023-03-10 22:55:33 +03:30

16 lines
353 B
TypeScript

import { prisma } from "@/lib/api/db";
export default async (userId: number, collectionId: number) => {
const check = await prisma.collection.findFirst({
where: {
AND: {
id: collectionId,
OR: [{ ownerId: userId }, { members: { some: { userId } } }],
},
},
include: { members: true },
});
return check;
};