-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