✨ feat: create bulk insertion for characters
This commit is contained in:
@ -0,0 +1,18 @@
|
||||
import { Prisma } from "@prisma/client";
|
||||
import { AppError } from "../../../helpers/error/instances/app";
|
||||
import { prisma } from "../../../utils/databases/prisma/connection";
|
||||
|
||||
export const bulkInsertCharactersRepository = async (
|
||||
payload: Prisma.CharacterUpsertArgs["create"],
|
||||
) => {
|
||||
try {
|
||||
return await prisma.character.upsert({
|
||||
where: { malId: payload.malId },
|
||||
create: payload,
|
||||
update: payload,
|
||||
select: { id: true },
|
||||
});
|
||||
} catch (error) {
|
||||
throw new AppError(500, "Failed to bulk insert characters", error);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user