el.xwx.moe/lib/api/controllers/collections/getCollections.ts

27 lines
543 B
TypeScript
Raw Normal View History

2023-02-18 21:32:02 -06:00
import { prisma } from "@/lib/api/db";
export default async function getCollection(userId: number) {
2023-02-18 21:32:02 -06:00
const collections = await prisma.collection.findMany({
where: {
OR: [
{ ownerId: userId },
{ members: { some: { user: { id: userId } } } },
],
},
include: {
2023-04-27 18:13:21 -05:00
members: {
include: {
user: {
select: {
email: true,
name: true,
},
},
},
},
2023-02-18 21:32:02 -06:00
},
});
2023-03-28 02:31:50 -05:00
return { response: collections, status: 200 };
2023-02-18 21:32:02 -06:00
}