Order.js 1.62 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
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
Jiwon Yoon's avatar
Jiwon Yoon committed
27
28
29
            },
            checked: {
                type: Boolean
Jiwon Yoon's avatar
Jiwon Yoon committed
30
31
32
            }
        }
    ],
Jiwon Yoon's avatar
Jiwon Yoon committed
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
    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
Jiwon Yoon's avatar
Jiwon Yoon committed
54
        }
55
    },
Jiwon Yoon's avatar
Jiwon Yoon committed
56
    completeState: {
57
58
59
60
61
        type: String,
        required: true
    },
    paymentInfo: {
        bank: {
Jiwon Yoon's avatar
Jiwon Yoon committed
62
63
            type: String,
            required: true
64
65
        },
        depositor: {
Jiwon Yoon's avatar
Jiwon Yoon committed
66
67
            type: String,
            required: true
68
69
        },
        deadline: {
Jiwon Yoon's avatar
Jiwon Yoon committed
70
71
            type: String,
            required: true
72
73
        }
    },
Jiwon Yoon's avatar
Jiwon Yoon committed
74
75
76
77
78
79
80
81
82
    total: {
        type: Number,
        required: true
    }
}, {
    timestamps: true
})

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