Keep/keep-notes/scripts/seed-user.ts

23 lines
544 B
TypeScript

import { PrismaClient } from '@prisma/client'
import bcrypt from 'bcryptjs'
const prisma = new PrismaClient()
async function main() {
const hashedPassword = await bcrypt.hash('password123', 10)
const user = await prisma.user.upsert({
where: { email: 'test@example.com' },
update: {},
create: {
email: 'test@example.com',
name: 'Test User',
password: hashedPassword,
},
})
console.log('User created:', user)
}
main()
.catch(e => console.error(e))
.finally(async () => await prisma.$disconnect())