Order.js 1.29 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
        }
Jiwon Yoon's avatar
Jiwon Yoon committed
55
    }
Jiwon Yoon's avatar
Jiwon Yoon committed
56
57
58
59
60
61
62
63
64
65
    ,
    total: {
        type: Number,
        required: true
    }
}, {
    timestamps: true
})

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