31 lines
735 B
TypeScript
31 lines
735 B
TypeScript
import { PrismaClient } from '@prisma/client'
|
|
import * as bcrypt from 'bcrypt'
|
|
|
|
const prisma = new PrismaClient()
|
|
|
|
async function main() {
|
|
const emmyPassword = await bcrypt.hash("Emmy", 10)
|
|
const emmy = await prisma.player.upsert({
|
|
where: { id: 1 },
|
|
update: { name: 'Emmy' },
|
|
create: { name: 'Emmy', password: emmyPassword },
|
|
})
|
|
|
|
const taminaPassword = await bcrypt.hash("Tamina", 10)
|
|
const tamina = await prisma.player.upsert({
|
|
where: { id: 2 },
|
|
update: { name: 'Tamina' },
|
|
create: { name: 'Tamina', password: taminaPassword },
|
|
})
|
|
console.log({ emmy, tamina })
|
|
}
|
|
|
|
main()
|
|
.catch((e) => {
|
|
console.error(e)
|
|
process.exit(1)
|
|
})
|
|
.finally(async () => {
|
|
await prisma.$disconnect()
|
|
})
|