38 lines
762 B
TypeScript
38 lines
762 B
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'
|
|
}
|
|
});
|
|
|
|
const bob = await prisma.user.upsert({
|
|
where: { email: 'bob@prisma.io' },
|
|
update: {},
|
|
create: {
|
|
email: 'bob@prisma.io',
|
|
name: 'Bob',
|
|
password: 'Aa12345678'
|
|
}
|
|
});
|
|
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 };
|