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

kusang96's avatar
dd    
kusang96 committed
3
4
const { String, Number } = mongoose.Schema.Types

Jiwon Yoon's avatar
Jiwon Yoon committed
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
dd    
kusang96 committed
36
        type: [String],
Jiwon Yoon's avatar
Jiwon Yoon committed
37
38
39
40
41
42
        required: true,
    },
    description: {
        type: String,
        required: true,
    },
kusang96's avatar
dd    
kusang96 committed
43
    main_imgUrl: {
Jiwon Yoon's avatar
Jiwon Yoon committed
44
        type: String,
kusang96's avatar
dd    
kusang96 committed
45
        required: true
Jiwon Yoon's avatar
Jiwon Yoon committed
46
    },
kusang96's avatar
dd    
kusang96 committed
47
48
    detail_imgUrls: {
        type: [String]
Jiwon Yoon's avatar
Jiwon Yoon committed
49
50
51
52
53
54
    }
}, {
    timestamps: true
})

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