import { Prisma, PrismaClient } from '@prisma/client' const prisma = new PrismaClient() //필요 설치 : npm install -D typescript ts-node @types/node //Project 디렉토리에서 실행: npx prisma db seed const userDatas: Prisma.UserCreateInput[] = [ { email: 'choi.jh@idcjp.jp', name: '최준흠', password: '1234', role: 'ADMIN' }, { email: 'user1@idcjp.jp', name: '사용자1', password: '1234', role: 'USER' }, { email: 'user2@idcjp.jp', name: '사용자2', password: '1234', role: 'USER' }, { email: 'user3@idcjp.jp', name: '사용자3', password: '1234', role: 'USER' } ] const transferUser = async () => { const users = [] for (const userData of userDatas) { const user = prisma.user.create({ data: userData }) users.push(user) } return await prisma.$transaction(users) } const main = async () => { console.log(`Start User seeding ...`) await transferUser() console.log(`Seeding User finished.`) } main() .catch((e) => { console.error(e) process.exit(1) }) .finally(async () => { await prisma.$disconnect() })