Cart.js 811 Bytes
Newer Older
Jiwon Yoon's avatar
22    
Jiwon Yoon committed
1
2
import mongoose from 'mongoose'

Kim, Subin's avatar
정리    
Kim, Subin committed
3
const { String, Number, ObjectId } = mongoose.Schema.Types
4
5
const CartSchema = new mongoose.Schema({
    userId: {
Jiwon Yoon's avatar
qwr    
Jiwon Yoon committed
6
7
        type: ObjectId,
        ref: 'User'
8
    },
Jiwon Yoon's avatar
qwr    
Jiwon Yoon committed
9
10
11
12
13
14
15
    products: {
        type: [
            {
                count: {
                    type: Number,
                    default: 1
                },
16
                productId: {
Jiwon Yoon's avatar
qwr    
Jiwon Yoon committed
17
18
                    type: ObjectId,
                    ref: 'Product'
19
                },
Jiwon Yoon's avatar
Jiwon Yoon committed
20
                size: {
21
22
                    type: String
                },
Jiwon Yoon's avatar
Jiwon Yoon committed
23
                color: {
24
                    type: String
Jiwon Yoon's avatar
Jiwon Yoon committed
25
26
27
                },
                checked: {
                    type: Boolean
Jiwon Yoon's avatar
qwr    
Jiwon Yoon committed
28
29
30
                }
            }
        ]
Jiwon Yoon's avatar
22    
Jiwon Yoon committed
31
32
    }
})
Kim, Subin's avatar
정리    
Kim, Subin committed
33

Jiwon Yoon's avatar
22    
Jiwon Yoon committed
34
export default mongoose.models.Cart || mongoose.model('Cart', CartSchema)