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

Commit

Permalink
fix: seeds
Browse files Browse the repository at this point in the history
  • Loading branch information
nmashchenko committed Dec 31, 2023
1 parent 9ffc442 commit a1c8114
Showing 1 changed file with 27 additions and 16 deletions.
43 changes: 27 additions & 16 deletions server/src/libs/database/seeds/user/user-seed.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,21 +337,32 @@ export class UserSeedService {
);
}

// await this.repository.save(
// this.repository.create({
// fullName: 'John Deer',
// email: '[email protected]',
// password: 'secret',
// role: {
// id: RoleEnum.user,
// name: 'Admin',
// },
// status: {
// id: StatusEnum.active,
// name: 'Active',
// },
// })
// );
const userForTests = await this.repository.count({
where: {
role: {
id: RoleEnum.user,
},
fullName: 'John Deer',
},
});

if (!userForTests) {
await this.repository.save(
this.repository.create({
fullName: 'John Deer',
email: '[email protected]',
password: 'secret',
role: {
id: RoleEnum.user,
name: 'Admin',
},
status: {
id: StatusEnum.active,
name: 'Active',
},
})
);
}

const countUser = await this.repository.count({
where: {
Expand All @@ -361,7 +372,7 @@ export class UserSeedService {
},
});

if (!countUser) {
if (countUser === 1) {
for (let i = 0; i < 50; i++) {
const randomSpeciality = this.getRandomItemFromArray([
'Developer',
Expand Down

0 comments on commit a1c8114

Please sign in to comment.