Skip to content

Commit 2223abf

Browse files
authored
Fix add code to update loggedusermodel (#156)
* Fix add code to update loggedusermodel * add fix for blog seeds
1 parent fa2bf88 commit 2223abf

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

Diff for: src/resolvers/applicationStageResolver.ts

+22-1
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,28 @@ export const applicationStageResolvers: any = {
413413
},
414414
}
415415
);
416-
416+
const updatedApplicant = await TraineeApplicant.findOne({
417+
_id: applicantId,
418+
})
419+
.populate("email")
420+
.lean();
421+
422+
const email = updatedApplicant?.email;
423+
424+
if (email) {
425+
await LoggedUserModel.updateOne(
426+
{ email },
427+
{
428+
$set: {
429+
applicationPhase: nextStage,
430+
status: "Admitted",
431+
role: traineeRole._id,
432+
},
433+
}
434+
);
435+
} else {
436+
throw new Error("Email not found for the provided applicant ID");
437+
}
417438
const notification2 = await ApplicantNotificationsModel.create({
418439
userId: user!._id,
419440
message,

Diff for: src/seeders/blogs.ts

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { BlogModel } from "../models/blogModel";
2+
import { CommentModel } from "../models/commentModel";
3+
import { LikeModel } from "../models/likeModel";
4+
import { CommentLikeModel } from "../models/commentLike";
5+
import { CommentReplyModel } from "../models/CommentReply";
6+
7+
const seedBlogs = async () => {
8+
await BlogModel.deleteMany({});
9+
await CommentModel.deleteMany({});
10+
await CommentLikeModel.deleteMany({});
11+
await LikeModel.deleteMany({});
12+
await CommentReplyModel.deleteMany({});
13+
};
14+
15+
export default seedBlogs;

Diff for: src/seeders/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { connect } from '../database/db.config'
2+
import seedBlogs from "./blogs";
23

34
import seedDeleteTrainee from './DelTrainee';
45
import seedJobs from './jobs';
@@ -16,5 +17,6 @@ connect().then(async () => {
1617
await seedCohorts();
1718
await seedJobs();
1819
await seedApplications();
20+
await seedBlogs();
1921
process.exit()
2022
})

0 commit comments

Comments
 (0)