traintrape-moi/server/prisma/seed.ts

31 lines
735 B
TypeScript
Raw Normal View History

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:24:41 +00:00
const prisma = new PrismaClient()
async function main() {
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({
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({
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
})
console.log({ emmy, tamina })
}
main()
.catch((e) => {
2024-12-07 09:24:41 +00:00
console.error(e)
process.exit(1)
})
.finally(async () => {
2024-12-07 09:24:41 +00:00
await prisma.$disconnect()
})