You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
445 B
JavaScript

const mongoose = require('mongoose');
const cartItemSchema = new mongoose.Schema({
productId: {
type: mongoose.Schema.Types.ObjectId,
ref: 'Product',
required: true,
},
quantity: {
type: Number,
default: 1,
},
});
const cartSchema = new mongoose.Schema({
userId: {
type: String,
required: true,
},
items: [cartItemSchema],
});
const Cart = mongoose.model('Cart', cartSchema);
module.exports = Cart;