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

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

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: {
Jiwon Yoon's avatar
Jiwon Yoon committed
36
        type: Array,
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
    detail_imgUrls: {
Jiwon Yoon's avatar
Jiwon Yoon committed
48
        type: Array
Jiwon Yoon's avatar
Jiwon Yoon committed
49
50
51
52
53
54
    }
}, {
    timestamps: true
})

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