✨ feat: endpoint for bulk insert video
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 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);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user