import prisma from "../../prisma"

async function createAnonymousDB<T>(payload: T) {
  const player = await prisma.player.create({
    data: {
      anonymous: true,
    },
  })
  // .catch((err: any) => {
  //     if (err.code === 11000) {
  //         return Promise.reject({
  //             message: `Duplicate key error while creating Player in DB!`,
  //             statusCode: 409,
  //             solved: true,
  //             type: 'warn'
  //         })
  //     } else {
  //         console.log(err)
  //         return Promise.reject({
  //             message: `Unknown error while creating Player in DB.`,
  //             solved: false
  //         })
  //     }
  // })
  return { ...payload, player }
}

export default createAnonymousDB
