Some refactor
This commit is contained in:
22
src/actions/artworks/getArtworks.ts
Normal file
22
src/actions/artworks/getArtworks.ts
Normal 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
|
||||
}
|
||||
})
|
||||
}
|
||||
16
src/actions/categories/getCategories.ts
Normal file
16
src/actions/categories/getCategories.ts
Normal 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" }],
|
||||
})
|
||||
}
|
||||
7
src/actions/tags/getTags.ts
Normal file
7
src/actions/tags/getTags.ts
Normal file
@ -0,0 +1,7 @@
|
||||
"use server"
|
||||
|
||||
import { prisma } from "@/lib/prisma"
|
||||
|
||||
export async function getTags() {
|
||||
return await prisma.artTag.findMany({ orderBy: { sortIndex: "asc" } })
|
||||
}
|
||||
Reference in New Issue
Block a user