Skip to content

Commit

Permalink
Update questionController.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
KhoonSun47 committed Sep 28, 2024
1 parent 30f8d8f commit e5a32f0
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion services/question/src/controllers/questionController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,12 @@ export const updateQuestion = async (req: Request, res: Response) => {

try {
const existingQuestion = await Question.findOne({
$or: [{ title: updates.title }, { description: updates.description }],
$and: [
{
$or: [{ title: updates.title }, { description: updates.description }],
},
{ id: { $ne: parseInt(id, 10) } },
],
}).collation({ locale: 'en', strength: 2 });
if (existingQuestion) {
return handleBadRequest(res, 'A question with the same title or description already exists.');
Expand Down

0 comments on commit e5a32f0

Please sign in to comment.