这里doc我已经用mongoose查询过来了已经有了如下:
{ _id: 5abde50b0bbd63c05201e938,
productImage: '1.jpg',
salePrice: 200,
productName: '小米音响',
productId: '201710007' }
if(doc){
//但是我这两个属性没有加上
doc.productNum = "1";
doc.checked = "1";
//但是我这两个属性没有加上
userdoc.cartList.push(doc);
userdoc.save(function(err2,doc){
if(err2){
res.json({
status:'1',
msg:err2.message
})
}else{
res.json({
status:'0',
msg:"",
result:"成功"
})
}
});
这是我的数据模型
var mongoose = require('mongoose');
var userSchema = new mongoose.Schema({
"userId":String,
"userName":String,
"userPwd":String,
"orderList":Array,
"cartList":[
{
"productId":String,
"productName":String,
"salePrice":String,
"productImage":String,
"checked":String,
"productNum":String
}
],
"addressList":Array
});
module.exports = mongoose.model("us",userSchema);
希望各位大师帮我解释下为什么
悄悄然