el.xwx.moe/lib/api/controllers/links/getLinks.ts
2023-06-13 22:49:37 +03:30

32 lines
598 B
TypeScript

import { prisma } from "@/lib/api/db";
export default async function getLink(userId: number) {
const links = await prisma.link.findMany({
where: {
collection: {
OR: [
{
ownerId: userId,
},
{
members: {
some: {
userId,
},
},
},
],
},
},
include: {
tags: true,
collection: true,
pinnedBy: {
where: { id: userId },
select: { id: true },
},
},
});
return { response: links, status: 200 };
}