-
Notifications
You must be signed in to change notification settings - Fork 82
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
PTBC#9 Patrick Kok #39
base: main
Are you sure you want to change the base?
Conversation
…ting in the controller using input received
…ighting_categories
super(model); | ||
} | ||
|
||
async getCategory(req, 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.
async getCategory(req, res) { | |
async getCategories(req, res) { |
plural as it returns potentially all categories
whereCategoryName | ||
? { where: { categoryName: whereCategoryName } } | ||
: undefined | ||
); |
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.
whereCategoryName | |
? { where: { categoryName: whereCategoryName } } | |
: undefined | |
); | |
...(whereCategoryName && { where: { categoryName: whereCategoryName }}) | |
); |
async createCategory(req, res) { | ||
const categoryName = req.body.name; | ||
try { | ||
const newCategory = await this.model.create({ category: categoryName }); |
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.
what if categoryName is undefined?
const { sightingId } = req.params; | ||
try { | ||
const comments = await this.model.findAll({ | ||
where: { sighting_id: sightingId }, |
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.
What if sightingId is undefined? Best to always validate request body and params first before using them!
My submission for the Bigfoot-SQL exrcises