I’m working on a multivendor cake selling project.
the situation is the user can customize their cakes.
to store that in mongo I can do simple post method and add it to mongo schema but the user info(id,name,phone,address) should be there too.
how can I store the user info in the customize cake schema?
code I wrote is below.
exports.addCustomCake=(req,res)=>{
customCakeModel({
user_id:req.saved_user._id,
order_By:req.saved_user.name,
phone:req.saved_user.phone,
address:req.saved_user.address
weight:req.body.weight,
flavour:req.body.flavour,
shape:req.body.shape,
layers:req.body.layers,
sponge:req.body.sponge,
cakeType:req.body.cakeType,
creamLevel:req.body.creamLevel,
fondantLevel:req.body.fondantLevel,
fondantCreamLevel:req.body.fondantCreamLevel,
paintCake:req.body.paintCake,
fillings:req.body.fillings,
effects:req.body.effects,
writingOnCake:req.body.writingOnCake,
}).save((err,customCake)=>{
if(!err){
res.status(200).json({
status:'success',
result:customCake,
message:'Custom cake added...'
});
}else{
res.status(404).json({
result:err,
message:'Custom cake add failed.'
})
}
})
}