Monday, 3 April 2017

how to make a valid search functionality

I'm making a search functionality. Below is My Code and User stories. I'm able to pass only the first User Story but not with the other stories. Can someone please help me out.

User Stories: 1) As an User if I search with Skills and location I should get the results which matched with the query. 2) As an User if I search with only Skills still I should get the results which matched with the query. 3) As an User if I search with only Location still I should get the results which matched with the query. 4) As an User if I search with invalid skills (J, A, B) or location I shouldn't get the results which does matched the query..

var search = {

    get: function (req, res) {
        var locationQuery = req.params.locationQuery,
        skillsQuery = req.params.skillsQuery;

        Jobs.find({state: { "$regex": locationQuery, "$options": "i" }, Skills: { "$regex": skillsQuery, "$options": "i" }}, function(err, result) {
            if (err) {
                console.log('Not a Valid Search');
                res.status(500).send(err, 'Not a Valid Search');
            }else {
                res.json(result);
            }            
        });
    }
};



via Arjun

No comments:

Post a Comment