✨ feat: create bulk insert for episode endpoint
This commit is contained in:
@ -0,0 +1,26 @@
|
||||
import { Prisma } from "@prisma/client";
|
||||
import { AppError } from "../../../helpers/error/instances/app";
|
||||
import { prisma } from "../../../utils/databases/prisma/connection";
|
||||
import { generateUUIDv7 } from "../../../helpers/databases/uuidv7";
|
||||
|
||||
export const bulkInsertEpisodesRepository = async (
|
||||
payload: Omit<Prisma.EpisodeUncheckedCreateInput, "id">,
|
||||
) => {
|
||||
try {
|
||||
return await prisma.episode.upsert({
|
||||
where: {
|
||||
mediaId_episode: {
|
||||
mediaId: payload.mediaId as string,
|
||||
episode: payload.episode as number,
|
||||
},
|
||||
},
|
||||
update: payload,
|
||||
create: {
|
||||
id: generateUUIDv7(),
|
||||
...payload,
|
||||
},
|
||||
});
|
||||
} catch (err) {
|
||||
throw new AppError(500, "Failed to bulk insert episodes", err);
|
||||
}
|
||||
};
|
||||
@ -1,7 +1,6 @@
|
||||
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";
|
||||
import { generateUUIDv7 } from "../../../helpers/databases/uuidv7";
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user