51 lines
1.0 KiB
TypeScript
51 lines
1.0 KiB
TypeScript
import { PrismaClient } from '@prisma/client';
|
|
const prisma = new PrismaClient();
|
|
|
|
async function user() {
|
|
const alice = await prisma.user.upsert({
|
|
where: { email: 'alice@prisma.io' },
|
|
update: {},
|
|
create: {
|
|
email: 'alice@prisma.io',
|
|
name: 'Alice',
|
|
password: 'Aa12345678',
|
|
emailVerified: new Date(),
|
|
},
|
|
});
|
|
|
|
await prisma.user.upsert({
|
|
where: { email: 'demo@minimals.cc' },
|
|
update: {},
|
|
create: {
|
|
email: 'demo@minimals.cc',
|
|
name: 'Demo',
|
|
password: '@2Minimal',
|
|
emailVerified: new Date(),
|
|
},
|
|
});
|
|
|
|
await prisma.user.upsert({
|
|
where: { email: 'bob@prisma.io' },
|
|
update: {},
|
|
create: {
|
|
email: 'bob@prisma.io',
|
|
name: 'Bob',
|
|
password: 'Aa12345678',
|
|
emailVerified: new Date(),
|
|
},
|
|
});
|
|
console.log('seed user done');
|
|
}
|
|
|
|
const userSeed = user()
|
|
.then(async () => {
|
|
await prisma.$disconnect();
|
|
})
|
|
.catch(async (e) => {
|
|
console.error(e);
|
|
await prisma.$disconnect();
|
|
process.exit(1);
|
|
});
|
|
|
|
export { userSeed };
|