aboutsummaryrefslogtreecommitdiff
path: root/server/models/Product.js
blob: f825a8bee45624269e3aaf1276d948e48f2bb2e5 (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,
    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;