diff options
Diffstat (limited to 'server/models/Product.js')
-rw-r--r-- | server/models/Product.js | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/server/models/Product.js b/server/models/Product.js new file mode 100644 index 0000000..f825a8b --- /dev/null +++ b/server/models/Product.js @@ -0,0 +1,26 @@ +const mongoose = require('mongoose'); + +const ProductSchema = new mongoose.Schema({ + name: { + type: String, + required: [true, "Product must have a name."], + maxLength: [100, "Product name can't have more then 100 characters."] + }, + description: { + type: String, + required: false + }, + imagePath: { + type: String, + required: false, + maxLength: [256, "Product's image path can't have more then 256 characters."] + }, + price: { + type: Number, + required: [true, "Product must have a price."] + } +}); + +const ProductModel = new mongoose.model('Product', ProductSchema); + +module.exports = ProductModel; |