mirror of
https://github.com/BradNut/boredgame
synced 2025-09-08 17:40:22 +00:00
31 lines
676 B
TypeScript
31 lines
676 B
TypeScript
import { PrismaClient } from '@prisma/client';
|
|
import userData from '../src/lib/data.json' assert { type: 'json' };
|
|
|
|
const prisma = new PrismaClient();
|
|
|
|
async function main() {
|
|
console.log(`Start seeding ...`);
|
|
|
|
for (const p of userData) {
|
|
const user = await prisma.user.create({
|
|
data: {
|
|
firstName: p.user.firstName,
|
|
lastName: p.user.lastName,
|
|
email: p.user.email,
|
|
username: p.user.username
|
|
}
|
|
});
|
|
console.log(`Created user with id: ${user.id}`);
|
|
}
|
|
console.log(`Seeding finished.`);
|
|
}
|
|
|
|
main()
|
|
.then(async () => {
|
|
await prisma.$disconnect();
|
|
})
|
|
.catch(async (e) => {
|
|
console.error(e);
|
|
await prisma.$disconnect();
|
|
process.exit(1);
|
|
});
|