Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add industry domain and preferred branches to the station model and their search filters #20

Closed
wants to merge 3 commits into from

Conversation

amey-g
Copy link

@amey-g amey-g commented Oct 1, 2020

#2 Please check the changes made. I have made the required changes to the station model as well as the search filters for them.

@@ -29,9 +29,17 @@ router.get('/api/1', async (req, res) => {
queries.location = { $regex: new RegExp(req.query.location, 'i') };
}

if (req.query.industryDomain) {
queries.location = { $regex: new RegExp(req.query.industryDomain, 'i') };
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

queries.location?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I'll fix them up

}

if (req.query.branch) {
queries.location = { $regex: new RegExp(req.query.branch, 'i') };
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

queries.location?
You cannot use regex with regex with an enum

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay I'll read up and fix it.

Copy link
Author

@amey-g amey-g left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried making the required changes, hope this works.

}

if (req.query.branch) {
queries.branches = { $in: [new RegExp(req.query.branch, 'i')] };
Copy link
Collaborator

@pratham1002 pratham1002 Oct 3, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had recommended using the $in operator to get rid of the regex

if (req.query.branch) {
    const branches = req.req.query.tags.split(' ');
    queries.branches = { $in: branches };
}

This will allow filtering multiple branches at once. when they are provided as a comma separated list.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay. I'll replace the code with this. Sorry, I had not used regex before. Thanks for helping out.

@amey-g amey-g closed this by deleting the head repository Aug 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants