Order.js 1.3 KB
Newer Older
Jiwon Yoon's avatar
Jiwon Yoon committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import mongoose from 'mongoose'

const { ObjectId, Number, String } = mongoose.Schema.Types

const OrderSchema = new mongoose.Schema({
    userId: {
        type: ObjectId,
        ref: 'User'
    },
    products: [
        {
            productId: {
                type: ObjectId,
                ref: 'Product'
            },
            count: {
                type: Number,
                required: true
            },
            size: {
                type: String,
                required: true
            },
            color: {
                type: String,
                required: true
            }
        }
    ],
    receiverInfo: 
        {
            name: {
                type:String,
                required:true
            },
            tel: {
                type: String,
                required:true
            },
            postalCode:{
                type:String,
                required:true
            },
            address: {
                type: String,
                required: true
            },
            address2: {
                type: String,
                required: true
            }
        }
    ,
    total: {
        type: Number,
        required: true
    }
}, {
    timestamps: true
})

export default mongoose.models.Order || mongoose.model('Order', OrderSchema)