21 lines
560 B
TypeScript
21 lines
560 B
TypeScript
import type { Player, Prisma } from "@prisma/client"
|
|
import prisma from "../../prisma"
|
|
import sendError, { API } from "./sendError"
|
|
import { rejectionErrors } from "../errors"
|
|
|
|
async function updatePlayerDB(
|
|
context: API,
|
|
player: Player,
|
|
data: Prisma.PlayerUpdateInput,
|
|
next: (updatedPlayer: Player) => void
|
|
) {
|
|
if (!player.anonymous) return sendError(context, rejectionErrors.registered)
|
|
const updatedPlayer = await prisma.player.update({
|
|
where: { id: player.id },
|
|
data,
|
|
})
|
|
|
|
return next(updatedPlayer)
|
|
}
|
|
|
|
export default updatePlayerDB
|