Skip to content

Commit

Permalink
🚀 Updated seeds
Browse files Browse the repository at this point in the history
  • Loading branch information
PHPLukaas committed May 17, 2024
1 parent 2f0948c commit e8f2d3c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions backend-nest/prisma/seed.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import {PrismaClient, user_role} from '@prisma/client';
import { PrismaClient, user_role } from '@prisma/client';
import * as bcrypt from 'bcrypt';

const prisma = new PrismaClient();

async function main() {
const salt = await bcrypt.genSalt();

const user1 = await prisma.user.upsert({
where: { email: '[email protected]' },
update: {},
create: {
email: '[email protected]',
password: 'alicepassword',
password: await bcrypt.hash('alicepassword', salt),
firstname: 'Alice',
lastname: 'Doe',
role: user_role.STUDENT,
Expand All @@ -21,7 +24,7 @@ async function main() {
update: {},
create: {
email: '[email protected]',
password: 'bobpassword',
password: await bcrypt.hash('bobpassword', salt),
firstname: 'Bob',
lastname: 'Smith',
role: user_role.ADMIN,
Expand All @@ -31,7 +34,6 @@ async function main() {

console.log({ user1, user2 });
}

main()
.catch((e) => {
console.error(e);
Expand Down

0 comments on commit e8f2d3c

Please sign in to comment.