Product.js 1006 Bytes
Newer Older
Jiwon Yoon's avatar
Jiwon Yoon committed
1
2
import mongoose from 'mongoose'

이재연's avatar
이재연 committed
3
const { String} = mongoose.Schema.Types
Jiwon Yoon's avatar
Jiwon Yoon committed
4
5
6
7
8
9
10

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
        required: true,
        default: 0
    },
23
24
25
26
27
28
29
30
    size: {
        type: Array,
        required: true
    },
    color: {
        type: Array,
        required: true
    },
Jiwon Yoon's avatar
Jiwon Yoon committed
31
32
33
34
35
    main_category: {
        type: String,
        required: true,
    },
    sub_category: {
kusang96's avatar
kusang96 committed
36
        type: Array,
Jiwon Yoon's avatar
Jiwon Yoon committed
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
        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)