Some refactor

This commit is contained in:
2025-12-28 18:41:31 +01:00
parent ce658849e9
commit eaf822d73a
11 changed files with 202 additions and 36 deletions

View File

@ -0,0 +1,22 @@
"use server"
import { prisma } from "@/lib/prisma"
export async function getSingleArtwork(id: string) {
return await prisma.artwork.findUnique({
where: { id },
include: {
// album: true,
// type: true,
file: true,
gallery: true,
metadata: true,
albums: true,
categories: true,
colors: { include: { color: true } },
// sortContexts: true,
tags: true,
variants: true
}
})
}

View File

@ -0,0 +1,16 @@
"use server"
import { prisma } from "@/lib/prisma"
export async function getCategoriesWithTags() {
return await prisma.artCategory.findMany({ include: { tags: true }, orderBy: { sortIndex: "asc" } })
}
export async function getCategoriesWithCount() {
return await prisma.artCategory.findMany({
include: {
_count: { select: { artworks: true, tags: true } },
},
orderBy: [{ sortIndex: "asc" }, { name: "asc" }],
})
}

View File

@ -0,0 +1,7 @@
"use server"
import { prisma } from "@/lib/prisma"
export async function getTags() {
return await prisma.artTag.findMany({ orderBy: { sortIndex: "asc" } })
}