mirror of
https://github.com/jorgev259/soc_site-astro.git
synced 2025-06-29 07:57:41 +00:00
Compare commits
2 commits
deb47c52e1
...
60a3ef3541
| Author | SHA1 | Date | |
|---|---|---|---|
| 60a3ef3541 | |||
| 63affb6b7f |
5 changed files with 24 additions and 15 deletions
|
|
@ -0,0 +1,10 @@
|
|||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the column `createdAt` on the `stores` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `updatedAt` on the `stores` table. All the data in the column will be lost.
|
||||
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE `stores` DROP COLUMN `createdAt`,
|
||||
DROP COLUMN `updatedAt`;
|
||||
|
|
@ -369,13 +369,11 @@ model series {
|
|||
}
|
||||
|
||||
model stores {
|
||||
id Int @id @default(autoincrement())
|
||||
url String? @db.VarChar(255)
|
||||
provider String? @db.VarChar(255)
|
||||
createdAt DateTime @db.DateTime(0)
|
||||
updatedAt DateTime @db.DateTime(0)
|
||||
albumId Int?
|
||||
album albums? @relation(fields: [albumId], references: [id], onDelete: Cascade, map: "stores_ibfk_1")
|
||||
id Int @id @default(autoincrement())
|
||||
url String? @db.VarChar(255)
|
||||
provider String? @db.VarChar(255)
|
||||
albumId Int?
|
||||
album albums? @relation(fields: [albumId], references: [id], onDelete: Cascade, map: "stores_ibfk_1")
|
||||
}
|
||||
|
||||
model studio {
|
||||
|
|
|
|||
|
|
@ -22,7 +22,9 @@ export const POST: APIRoute = async ({ request, locals }) => {
|
|||
|
||||
try {
|
||||
const albumRow = await prismaClient.$transaction(async (tx) => {
|
||||
const artistRows = body.artists.map((name: string) => ({ slug: slug(name), name }))
|
||||
const artistRows = body.artists
|
||||
?.split(',')
|
||||
.map((name: string) => ({ slug: slug(name.trim()), name: name.trim() }))
|
||||
|
||||
const albumRow = await tx.albums.create({
|
||||
data: {
|
||||
|
|
@ -36,7 +38,7 @@ export const POST: APIRoute = async ({ request, locals }) => {
|
|||
status: body.status,
|
||||
animations: { create: body.animations.map((id) => ({ animation: { connect: { id } } })) },
|
||||
artists: {
|
||||
create: artistRows.map((a) => ({
|
||||
create: artistRows?.map((a) => ({
|
||||
artist: {
|
||||
connectOrCreate: {
|
||||
create: a,
|
||||
|
|
@ -51,6 +53,7 @@ export const POST: APIRoute = async ({ request, locals }) => {
|
|||
platforms: { create: body.platforms.map((id) => ({ platform: { connect: { id } } })) },
|
||||
// albumHistories
|
||||
discs: { createMany: { data: body.discs } },
|
||||
stores: { createMany: { data: body.stores } },
|
||||
relatedAlbums: { create: body.related.map((id) => ({ relatedAlbum: { connect: { id } } })) }
|
||||
},
|
||||
include: { artists: { include: { artist: { select: { name: true } } } } }
|
||||
|
|
|
|||
|
|
@ -60,7 +60,8 @@ export const POST: APIRoute = async ({ request, locals }) => {
|
|||
platforms: { deleteMany: {}, create: platforms?.map((id) => ({ platform: { connect: { id } } })) },
|
||||
discs: { deleteMany: {}, createMany: { data: body.discs ?? [] } },
|
||||
relatedAlbums: { deleteMany: {}, create: related?.map((id) => ({ relatedAlbum: { connect: { id } } })) },
|
||||
downloads: { deleteMany: {} }
|
||||
downloads: { deleteMany: {} },
|
||||
stores: stores ? { deleteMany: {}, createMany: { data: stores } } : undefined
|
||||
}
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ export const AlbumBase = s.object({
|
|||
description: s.optional(s.string()),
|
||||
status: s.defaulted(s.enums(Object.values(AlbumStatus)), AlbumStatus.HIDDEN),
|
||||
animations: s.defaulted(s.array(coerceInt), []),
|
||||
artists: s.defaulted(s.array(s.string()), []),
|
||||
artists: s.defaulted(s.optional(s.string()), ''),
|
||||
categories: s.defaulted(s.array(s.string()), []),
|
||||
classifications: s.defaulted(s.array(s.string()), []),
|
||||
games: s.defaulted(s.array(s.string()), []),
|
||||
|
|
@ -40,7 +40,4 @@ export const AlbumBase = s.object({
|
|||
request: s.optional(coerceInt)
|
||||
})
|
||||
|
||||
export const EditAlbum = s.assign(
|
||||
s.partial(AlbumBase),
|
||||
s.object({ albumId: coerceInt, artists: s.optional(s.string()) })
|
||||
)
|
||||
export const EditAlbum = s.assign(s.partial(AlbumBase), s.object({ albumId: coerceInt }))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue