Product.js 895 Bytes
Newer Older
Jiwon Yoon's avatar
Jiwon Yoon committed
1
2
3
4
5
6
7
8
9
10
import mongoose from 'mongoose'

const { String, Number, Array } = mongoose.Schema.Types

const ProductSchema = new mongoose.Schema({
    pro_name: {
        type: String,
        required: true,
    },
    price: {
kusang96's avatar
kusang96 committed
11
        type: Number,
Jiwon Yoon's avatar
Jiwon Yoon committed
12
13
14
        required: true,
    },
    stock: {
kusang96's avatar
kusang96 committed
15
        type: Number,
Jiwon Yoon's avatar
Jiwon Yoon committed
16
17
18
        required: true
    },
    purchase: {
kusang96's avatar
kusang96 committed
19
        type: Number,
Jiwon Yoon's avatar
Jiwon Yoon committed
20
21
22
23
24
25
26
27
        required: true,
        default: 0
    },
    main_category: {
        type: String,
        required: true,
    },
    sub_category: {
kusang96's avatar
kusang96 committed
28
        type: Array,
Jiwon Yoon's avatar
Jiwon Yoon committed
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
        required: true,
    },
    description: {
        type: String,
        required: true,
    },
    main_image: {
        type: String,
        required: true,
    },
    detail_image: {
        type: String,
        required: true,
    }
}, {
    timestamps: true
})

export default mongoose.models.Product || mongoose.model('Product', ProductSchema)