-
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
createTag and getTag API #75
Conversation
Signed-off-by: ridhisjain <[email protected]>
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.
Just some minor changes.
Rest LGTM !
Co-authored-by: Chirag Jain <[email protected]>
263d659
to
efa0d87
Compare
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.
@ridhishjain I think getting tag by id is also necessary I guess. Like check if there is id in search string if so search it by id
, otherwise check if search
is available and search by search
.
efa0d87
to
a818ddc
Compare
Co-authored-by: Chirag Jain <[email protected]>
bdc99fe
to
314d431
Compare
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.
Cool !
const keyword = query.keyword || '' | ||
const searchId = query.id || '' | ||
pool.query( | ||
`SELECT * FROM tags WHERE id LIKE ? AND name LIKE ?`, |
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.
Actually I meant to say:
let query = ``;
const depArr = [];
if(searchId) {
query += `SELECT * FROM tags WHERE id = ?`;
depArr.push(searchId);
} else if(keyword) {
query += `SELECT * FROM tags LIKE ?`;
depArr.push(keyword);
}
pool.query(query, depArr, (err, res) => {
...
})
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.
Yeah, that's much better !
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.
complexity will be same in both cases....
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.
Nope ! this would be a bit faster , as it doesn't have AND , OR in SQL query..
Issue at work: #60
API implemented:
createTag
POST /tag
Admin only: create a taggetTag
GET /tag?search=keyword
: search for a tag