Answer the question
In order to leave comments, you need to log in
Shopping cart for an online store?
Made the user through sessions and further there is a question of realization of a basket. When you click the "Add to Cart" button next to a product, what should happen in order for the product to be added to the cart of this user? In the database for creating a user, the model is:
let mongoose = require('mongoose');
let User = new mongoose.Schema({
name:{
type:String,
unique:true,
required:true
},
password:{
type:String,
required:true
}
});
exports.User = mongoose.model('User',User);
Answer the question
In order to leave comments, you need to log in
let Cart = new mongoose.Schema({
userId: { type: String, required: true, index: true, ref: 'User' },
...
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question