aboutsummaryrefslogtreecommitdiff
path: root/server/models/Product.js
blob: a8ef10ea31bac571425429eb79ed59043cc66588 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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,
    default: "uploads/no-image.png",
    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;