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

add ProductSchema #5

Merged
merged 5 commits into from
May 21, 2022
Merged

add ProductSchema #5

merged 5 commits into from
May 21, 2022

Conversation

ssary
Copy link
Collaborator

@ssary ssary commented May 21, 2022

No description provided.

Copy link
Owner

@skittlesaur skittlesaur left a comment

Choose a reason for hiding this comment

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

  • Remove the id property in the products schema since it's already automatically generated by MongoDb.
  • The image is stored as a direct url, so a type of String would be enough
  • Don't forget the response status :D

const {Schema} = mongoose;

const productSchema = new Schema({
id: Number,
Copy link
Owner

Choose a reason for hiding this comment

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

This will add an additional property of id. MongoDb already handles that with new entries (_id).

category: String,
image:
{
type: Buffer,
Copy link
Owner

Choose a reason for hiding this comment

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

The image is passed as a direct URL. We wont store binary data so a type of String would make more sense here.

server/app.js Outdated
res.send(products);

else
res.send(products.slice(0,itemsPerPage));
Copy link
Owner

Choose a reason for hiding this comment

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

Don't forget the response status :D

category: String,
weight: Number,
measurement: String,
category: String,
Copy link
Owner

Choose a reason for hiding this comment

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

category is repeated

@ssary
Copy link
Collaborator Author

ssary commented May 21, 2022

Done

@skittlesaur skittlesaur merged commit e2ace59 into develop May 21, 2022
@skittlesaur skittlesaur deleted the ProductSchema branch May 24, 2022 22:36
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