Look at the code below, it's working perfectly;
function getRestaurant(req, res){
var restaurantId = req.params.id;
Restaurant.findById(restaurantId).populate({path: 'user'}).exec((err, restaurant) => {
if(err){
res.status(500).send({
message: 'Error na solicitação'
});
}else{
if(!restaurant){
res.status(404).send({
message: 'Não existe nenhum restaurante nesse registro'
});
}else{
res.status(200).send({
restaurant
});
}
}
});
}
Here's the result:
You may notice that it is listing the record according to _id of MongoDB, however what I really need is to filter the record according to id that is the very attribute of the entity where you can view potato-gratin .
Please, how do I change the algorithm for entity list id's attribute?