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

3
4
5
const { String, Number, Array, ObjectId } = mongoose.Schema.Types
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
qwr    
Jiwon Yoon committed
25
26
27
                }
            }
        ]
Jiwon Yoon's avatar
22    
Jiwon Yoon committed
28
29
30
    }
})
export default mongoose.models.Cart || mongoose.model('Cart', CartSchema)