-1
我的API在无法访问子对象的属性
http://52.24.34.186:3000/api/posts/
=========================== =============================
router.route('/users/root/:id').get(function(req, res) {
User.findOne()
.populate('countryId')
.populate('stateId')
.populate('districtId')
.populate('mandalId')
.populate('villageId')
exec({villageId._id: req.params.id}, function(err, userObj) {
if (err) {
return res.send(err);
}
res.json(userObj);
});
});
==>显示错误为 “意外的标记”。
at“exec({villageId._id:req.params.id},function(err,userObj){”
请有人帮助我吗?
感谢您的回答。即使在exec()之前保留点之后,我也遇到了同样的错误。 – Vasu
你可能是对的。但我需要检查'req.params.id'与我的villageId._id没有_id。怎么做? – Vasu
你是什么意思“检查'req.params.id'与我的villageId._id?” – mscdex