minor changes

This commit is contained in:
daniel31x13
2024-11-02 20:43:53 -04:00
parent 2e1e94112f
commit 4febe1ace5
21 changed files with 4603 additions and 21657 deletions
@@ -2,7 +2,7 @@ import { prisma } from "@/lib/api/db";
import { LinkRequestQuery, Order, Sort } from "@/types/global";
export default async function getLink(
query: Omit<LinkRequestQuery, "tagId" | "pinnedOnly">, takeAll = false
query: Omit<LinkRequestQuery, "tagId" | "pinnedOnly">
) {
const POSTGRES_IS_ENABLED =
process.env.DATABASE_URL?.startsWith("postgresql");
+22 -8
View File
@@ -1,15 +1,22 @@
import { prisma } from "@/lib/api/db";
export default async function getTags(userId?: number) {
export default async function getTags({
userId,
collectionId,
}: {
userId?: number;
collectionId?: number;
}) {
// Remove empty tags
await prisma.tag.deleteMany({
where: {
ownerId: userId,
links: {
none: {},
if (userId)
await prisma.tag.deleteMany({
where: {
ownerId: userId,
links: {
none: {},
},
},
},
});
});
const tags = await prisma.tag.findMany({
where: {
@@ -28,6 +35,13 @@ export default async function getTags(userId?: number) {
},
},
},
{
links: {
some: {
collectionId,
},
},
},
],
},
include: {