数据是这样的
{
"_id" : ObjectId("58c41d5d3eddd93e9ab5b078"),
"userId" : "100000077",
"cartList" : [
{
"productImage" : "note.jpg",
"salePrice" : 3549,
"productName" : "小米笔记本",
"productId" : "201710005",
"_id" : ObjectId("58c284e6117a2e6599abef5f")
},
{
"productImage" : "mi6.jpg",
"salePrice" : 2499,
"productName" : "小米6",
"productId" : "201710006",
"_id" : ObjectId("58c284f4117a2e6599abef60"),
"productNum" : "NaN"
},
{
"productImage" : "13.jpg",
"salePrice" : 2000,
"productName" : "Ear2000",
"productId" : "201710013",
"_id" : ObjectId("58e7053c98dab115d336b3f8")
}
],
"__v" : 33
}
如果这个数据的modal叫Users,如何通过mongoose的 Users.count方法得到cartList的下面元素的个数?
谢谢各位大神了!!!
huangzhong
相关分类