Skip to content

Commit

Permalink
question search added
Browse files Browse the repository at this point in the history
  • Loading branch information
Akalanka-1996 committed Feb 22, 2022
1 parent 193a849 commit dbeb49d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions backend/controller/questionController.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ const deleteQuestion = asyncHandler(async (req,res) => {

// search a question

const seachQuestion = asyncHandler(async (req, res) => {
const searchQuestion = asyncHandler(async (req, res) => {
const keyword = req.query.search ? {
$or: [
{ grade: { $regex: req.query.search, $options: "i"}},
Expand All @@ -124,4 +124,4 @@ const seachQuestion = asyncHandler(async (req, res) => {
res.send(questions)
})

module.exports = {getQuestions, createQuestion, getQuestionsById, updateQuestion, deleteQuestion, seachQuestion}
module.exports = {getQuestions, createQuestion, getQuestionsById, updateQuestion, deleteQuestion, searchQuestion}
4 changes: 2 additions & 2 deletions backend/routes/questions.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const router = require('express').Router()
const {getQuestions, getQuestionsById, createQuestion, updateQuestion, deleteQuestion, seachQuestion} = require('../controller/questionController')
const {getQuestions, getQuestionsById, createQuestion, updateQuestion, deleteQuestion, searchQuestion} = require('../controller/questionController')

const {protect} = require('../middleware/authMiddleware')
const {grantAccess} = require('../permission/permission')

router.route('/').get(getQuestions)
router.route('/getquestions').get(protect, seachQuestion)
router.route('/getquestions').get(protect, searchQuestion)
router.route('/create').post(protect, createQuestion)
router.route('/:id').get(getQuestionsById).put(protect, updateQuestion).delete(protect, deleteQuestion)

Expand Down

0 comments on commit dbeb49d

Please sign in to comment.