2024-12-07 09:24:41 +00:00
|
|
|
import { PrismaClient } from '@prisma/client'
|
2024-12-07 12:06:15 +00:00
|
|
|
import * as bcrypt from 'bcrypt'
|
2024-12-07 09:17:47 +00:00
|
|
|
|
2024-12-07 09:24:41 +00:00
|
|
|
const prisma = new PrismaClient()
|
2024-12-07 09:17:47 +00:00
|
|
|
|
|
|
|
async function main() {
|
2024-12-08 15:34:06 +00:00
|
|
|
const game = await prisma.game.create({ data: {} })
|
2024-12-07 12:06:15 +00:00
|
|
|
const emmyPassword = await bcrypt.hash("Emmy", 10)
|
2024-12-08 12:41:37 +00:00
|
|
|
const emmy = await prisma.player.upsert({
|
2024-12-07 09:17:47 +00:00
|
|
|
where: { id: 1 },
|
|
|
|
update: { name: 'Emmy' },
|
2024-12-07 12:06:15 +00:00
|
|
|
create: { name: 'Emmy', password: emmyPassword },
|
2024-12-07 09:24:41 +00:00
|
|
|
})
|
2024-12-07 12:06:15 +00:00
|
|
|
|
|
|
|
const taminaPassword = await bcrypt.hash("Tamina", 10)
|
2024-12-08 12:41:37 +00:00
|
|
|
const tamina = await prisma.player.upsert({
|
2024-12-07 09:17:47 +00:00
|
|
|
where: { id: 2 },
|
|
|
|
update: { name: 'Tamina' },
|
2024-12-07 12:06:15 +00:00
|
|
|
create: { name: 'Tamina', password: taminaPassword },
|
2024-12-07 09:24:41 +00:00
|
|
|
})
|
2024-12-08 15:34:06 +00:00
|
|
|
console.log({ game, emmy, tamina })
|
2024-12-07 09:17:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
main()
|
|
|
|
.catch((e) => {
|
2024-12-07 09:24:41 +00:00
|
|
|
console.error(e)
|
|
|
|
process.exit(1)
|
2024-12-07 09:17:47 +00:00
|
|
|
})
|
|
|
|
.finally(async () => {
|
2024-12-07 09:24:41 +00:00
|
|
|
await prisma.$disconnect()
|
|
|
|
})
|