init commit,
This commit is contained in:
37
03_source/cms_backend/prisma/seeds/user.ts
Normal file
37
03_source/cms_backend/prisma/seeds/user.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
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 };
|
Reference in New Issue
Block a user