el.xwx.moe/lib/api/controllers/links/getLinks.ts

32 lines
598 B
TypeScript
Raw Normal View History

2023-03-05 15:03:20 -06:00
import { prisma } from "@/lib/api/db";
export default async function getLink(userId: number) {
2023-03-28 02:31:50 -05:00
const links = await prisma.link.findMany({
2023-03-05 15:03:20 -06:00
where: {
collection: {
OR: [
{
2023-03-28 02:31:50 -05:00
ownerId: userId,
2023-03-05 15:03:20 -06:00
},
{
members: {
some: {
2023-03-28 02:31:50 -05:00
userId,
2023-03-05 15:03:20 -06:00
},
},
},
],
},
},
2023-03-10 13:25:33 -06:00
include: {
tags: true,
collection: true,
2023-06-13 14:19:37 -05:00
pinnedBy: {
where: { id: userId },
select: { id: true },
},
2023-03-10 13:25:33 -06:00
},
2023-03-05 15:03:20 -06:00
});
2023-03-28 02:31:50 -05:00
return { response: links, status: 200 };
2023-03-05 15:03:20 -06:00
}