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
    },
Jiwon Yoon's avatar
Jiwon Yoon committed
23
    sizes: {
24
        type: Array,
Jiwon Yoon's avatar
Jiwon Yoon committed
25
        required: true
26
    },
Jiwon Yoon's avatar
Jiwon Yoon committed
27
    colors: {
28
        type: Array,
Jiwon Yoon's avatar
Jiwon Yoon committed
29
        required: true
30
    },
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
        required: true,
    },
    description: {
        type: String,
        required: true,
    },
    main_image: {
Jiwon Yoon's avatar
0111    
Jiwon Yoon committed
44
        type: Array,
Jiwon Yoon's avatar
Jiwon Yoon committed
45
46
47
        required: true,
    },
    detail_image: {
Jiwon Yoon's avatar
0111    
Jiwon Yoon committed
48
        type: Array,
Jiwon Yoon's avatar
Jiwon Yoon committed
49
50
51
52
53
54
55
        required: true,
    }
}, {
    timestamps: true
})

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