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

PTBC#9 Patrick Kok #39

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

PTBC#9 Patrick Kok #39

wants to merge 7 commits into from

Conversation

patrickkok
Copy link

My submission for the Bigfoot-SQL exrcises

super(model);
}

async getCategory(req, res) {

Choose a reason for hiding this comment

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

Suggested change
async getCategory(req, res) {
async getCategories(req, res) {

plural as it returns potentially all categories

Comment on lines +12 to +15
whereCategoryName
? { where: { categoryName: whereCategoryName } }
: undefined
);

Choose a reason for hiding this comment

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

Suggested change
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 });

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 },

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!

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