-
Notifications
You must be signed in to change notification settings - Fork 3
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
Conversation
… search filters for them
backend/routers/psOne.js
Outdated
@@ -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') }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
queries.location?
There was a problem hiding this comment.
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
backend/routers/psOne.js
Outdated
} | ||
|
||
if (req.query.branch) { | ||
queries.location = { $regex: new RegExp(req.query.branch, 'i') }; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this 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.
backend/routers/psOne.js
Outdated
} | ||
|
||
if (req.query.branch) { | ||
queries.branches = { $in: [new RegExp(req.query.branch, 'i')] }; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
#2 Please check the changes made. I have made the required changes to the station model as well as the search filters for them.