-
Notifications
You must be signed in to change notification settings - Fork 8
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
Conversation
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.
- 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 ofString
would be enough - Don't forget the response status :D
server/model/Products.js
Outdated
const {Schema} = mongoose; | ||
|
||
const productSchema = new Schema({ | ||
id: Number, |
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.
This will add an additional property of id. MongoDb already handles that with new entries (_id).
server/model/Products.js
Outdated
category: String, | ||
image: | ||
{ | ||
type: Buffer, |
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.
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)); |
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.
Don't forget the response status :D
category: String, | ||
weight: Number, | ||
measurement: String, | ||
category: String, |
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.
category
is repeated
Done |
No description provided.