feat: endpoint for bulk insert video

This commit is contained in:
2026-01-30 15:56:43 +07:00
parent ab0c8afca4
commit 11a607b4da
7 changed files with 122 additions and 0 deletions

View File

@ -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 bulkInsertVideoRepository = async (
payload: Omit<Prisma.VideoUncheckedCreateInput, "id">,
) => {
try {
return await prisma.video.upsert({
where: {
serviceId_code: {
serviceId: payload.serviceId,
code: payload.code,
},
},
create: {
id: generateUUIDv7(),
...payload,
},
update: payload,
});
} catch (error) {
throw new AppError(500, "Error inserting video", error);
}
};