refactored/cleaned up API + added support for renaming tags

This commit is contained in:
daniel31x13
2023-10-23 00:28:39 -04:00
parent 24cced9dba
commit ed24685aaf
48 changed files with 603 additions and 305 deletions
+19 -13
View File
@@ -1,24 +1,30 @@
import { prisma } from "@/lib/api/db";
export default async function getPermission(
userId: number,
collectionId: number,
linkId?: number
) {
type Props = {
userId: number;
collectionId?: number;
linkId?: number;
};
export default async function getPermission({
userId,
collectionId,
linkId,
}: Props) {
if (linkId) {
const link = await prisma.link.findUnique({
const check = await prisma.collection.findFirst({
where: {
id: linkId,
},
include: {
collection: {
include: { members: true },
links: {
some: {
id: linkId,
},
},
},
include: { members: true },
});
return link;
} else {
return check;
} else if (collectionId) {
const check = await prisma.collection.findFirst({
where: {
AND: {