-
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 - Hong Yun #45
base: main
Are you sure you want to change the base?
Conversation
async createCategory(req, res) { | ||
try { | ||
const output = await this.model.create({ | ||
name: req.body.name, |
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 the request body is empty? Best to validate that first before creating a db record
super(sightingModel); | ||
this.sightingModel = sightingModel; | ||
this.commentModel = commentModel; | ||
this.categoryModel = categoryModel; | ||
} | ||
|
||
// Retrieve specific sighting | ||
async getOne(req, res) { | ||
const { sightingId } = req.params; |
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?
date: new Date(date), | ||
location: location, | ||
notes: notes, |
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.
Same here, best to validate the request body first to make sure the necessary properties are defined!
id: selectedCategoryIds, | ||
}, | ||
}); | ||
await sightingAdded.setCategories(selectedCategories); |
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 selectedCategories is empty?
No description provided.