Product.js 997 Bytes
Newer Older
kusang96's avatar
dd    
kusang96 committed
1
import mongoose, { mongo } from 'mongoose'
Jiwon Yoon's avatar
Jiwon Yoon committed
2

kusang96's avatar
dd    
kusang96 committed
3
4
5
6
7
8
9
10
const { String, Number } = mongoose.Schema.Types

const productschema = new mongoose.Schema ({
    pro_name: {
        type: String,
        required: true
    }
})
Jiwon Yoon's avatar
Jiwon Yoon committed
11
12
13
14
15
16
17

const ProductSchema = new mongoose.Schema({
    pro_name: {
        type: String,
        required: true,
    },
    price: {
kusang96's avatar
kusang96 committed
18
        type: Number,
Jiwon Yoon's avatar
Jiwon Yoon committed
19
20
21
        required: true,
    },
    stock: {
kusang96's avatar
kusang96 committed
22
        type: Number,
Jiwon Yoon's avatar
Jiwon Yoon committed
23
24
25
        required: true
    },
    purchase: {
kusang96's avatar
kusang96 committed
26
        type: Number,
Jiwon Yoon's avatar
Jiwon Yoon committed
27
28
29
30
31
32
33
34
        required: true,
        default: 0
    },
    main_category: {
        type: String,
        required: true,
    },
    sub_category: {
kusang96's avatar
dd    
kusang96 committed
35
        type: [String],
Jiwon Yoon's avatar
Jiwon Yoon committed
36
37
38
39
40
41
        required: true,
    },
    description: {
        type: String,
        required: true,
    },
kusang96's avatar
dd    
kusang96 committed
42
    main_imgUrl: {
Jiwon Yoon's avatar
Jiwon Yoon committed
43
        type: String,
kusang96's avatar
dd    
kusang96 committed
44
        required: true
Jiwon Yoon's avatar
Jiwon Yoon committed
45
    },
kusang96's avatar
dd    
kusang96 committed
46
47
    detail_imgUrls: {
        type: [String]
Jiwon Yoon's avatar
Jiwon Yoon committed
48
49
50
51
52
53
    }
}, {
    timestamps: true
})

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