Skip to content

Commit 363d91d

Browse files
authored
Merge pull request #41 from KhoonSun47/init-question
Minor Fix on Question Service
2 parents aaf5883 + e5a32f0 commit 363d91d

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

services/question/src/controllers/questionController.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,12 @@ export const updateQuestion = async (req: Request, res: Response) => {
201201

202202
try {
203203
const existingQuestion = await Question.findOne({
204-
$or: [{ title: updates.title }, { description: updates.description }],
204+
$and: [
205+
{
206+
$or: [{ title: updates.title }, { description: updates.description }],
207+
},
208+
{ id: { $ne: parseInt(id, 10) } },
209+
],
205210
}).collation({ locale: 'en', strength: 2 });
206211
if (existingQuestion) {
207212
return handleBadRequest(res, 'A question with the same title or description already exists.');

0 commit comments

Comments
 (0)