【发布时间】:2019-08-12 07:02:16
【问题描述】:
我只需要上图中每个对象中的 path。 我试过这样的事情
userRouter.post('/delete_products',function(req,res){
Collections.product.find({ "_id": req.body.id }, { "pimages.path": "1" },function(err,result){
if(err)
res.send(err)
else
res.send(result)
const map=result.map(user=>user.pimages.map(user=>user.path))
console.log(map);
})
})
[ [ '1552640783_mixer front.jpg', '1552640783_mixer back.jpg' ] ]
我是这样的。我期待以对象形式的数组输出
[{'1552640783_mixer front.jpg'},{......}]
提前致谢。
【问题讨论】:
-
在 Object 中,值被写为 name : value 对。我没有得到您预期结果背后的逻辑。