memfilter bidang dalam API dari Express
/*in controller
Api call url {{baseUrl}}/tours?fields=name,duration,price
*/
export.getAllTours= async(req,res)=> {
try{
if(req.query.fields){
const fields= req.query.fields.split(",").join(' ');
let query= query.select(fields); //name duration price
}
}catch(err){
console.log(err)
}
}
Shirshak kandel