Skip to content
This repository has been archived by the owner on Aug 23, 2024. It is now read-only.

Commit

Permalink
fix: requesting for backup
Browse files Browse the repository at this point in the history
  • Loading branch information
NotHydra committed Feb 11, 2024
1 parent d22259f commit 069262f
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
2 changes: 1 addition & 1 deletion apps/api/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
"executor": "@nx-tools/nx-prisma:seed",
"options": {
"schema": "apps/api/prisma/schema.prisma",
"script": "apps/api/prisma/seed.ts"
"script": "apps/api/src/seed.ts"
}
},
"prisma-validate": {
Expand Down
46 changes: 46 additions & 0 deletions apps/api/src/seed.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { $Enums, PrismaClient } from "@prisma/client";
//eslint-disable-next-line @nx/enforce-module-boundaries
import * as utils from "./util/encryption";

const prisma = new PrismaClient();
async function main() {
const operators = [1, 2, 3, 4, 5].map(async (number: number) => {
return await prisma.user.create({
data: {
name: `Operator ${number}`,
username: `operator${number}`,
password: await utils.hash(`operator${number}`),
phoneNumber: `+6281234567891${number}`,
role: $Enums.Role.operator,
active: true,
description: null,
},
});
});

const admin = [1, 2, 3, 4, 5].map(async (number: number) => {
return await prisma.user.create({
data: {
name: `Admin ${number}`,
username: `admin${number}`,
password: await utils.hash(`admin${number}`),
phoneNumber: `+6281234567892${number}`,
role: $Enums.Role.admin,
active: true,
description: null,
},
});
});

console.log({ operators, admin });
}

main()
.then(async () => {
await prisma.$disconnect();
})
.catch(async (e) => {
console.error(e);
await prisma.$disconnect();
process.exit(1);
});

0 comments on commit 069262f

Please sign in to comment.