🚧 wip: try to create character with VA in bulk

This commit is contained in:
2026-01-24 22:02:34 +07:00
parent 7d26ca7f7b
commit fe10412f1a
9 changed files with 153 additions and 13 deletions

View File

@ -0,0 +1,36 @@
import { Prisma } from "@prisma/client";
import { AppError } from "../../../helpers/error/instances/app";
import { prisma } from "../../../utils/databases/prisma/connection";
import { MediaFullInfoResponse } from "../types/mediaFullInfo.type";
/**
* Media Payload Construction and Upsert
*
* This section constructs the payload for the media insertion or update.
* It gathers all necessary information from the media data, including
* title, alternative titles, slug, associated genres and studios, score,
* images, status, airing dates, synopsis, age rating, media type, source,
* and other relevant details. This payload is then used in an upsert
* operation to ensure that the media record is either created or updated
* in the database.
*
* @param data - The full media data for constructing the media payload.
* @returns The inserted or updated media record.
*/
export const InsertMediaRepository = async ({
malId,
payload,
}: {
malId: number;
payload: Prisma.MediaUpsertArgs["create"];
}) => {
try {
return await prisma.media.upsert({
where: { malId },
update: payload,
create: payload,
});
} catch (error) {
throw new AppError(500, "Failed to insert media", error);
}
};