Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

fields filtering in api from 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)
}
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: Any array in JSON object is not empty 
Javascript :: how to hide prerendered page button in nextjs 
Javascript :: How can I configure multiple sub domains in Express.js or Connect.js 
Javascript :: request submit form 
Javascript :: remember me option in firebase + react 
Javascript :: boilerplate functional component for DataGrid 
Javascript :: javascript check if key is keydown is charcter 
Javascript :: TypeError: (intermediate value).addBooks is not a function in js 
Javascript :: json query rails c 
Javascript :: coercion in javascript mdn 
Javascript :: Remove # id From URL When Clicked On Href Link 
Javascript :: angular 13 deploy on tomcat 9 
Javascript :: javascript object access time complexity 
Javascript :: Creating getLastBlock Object for blockchain 
Javascript :: add defer in tag manager 
Javascript :: javascript quotes 
Javascript :: repate element every 2 seconds 
Javascript :: Object.entries() To Use For Of On JSON 
Javascript :: The JavaScript call() Method 
Javascript :: javascript hide div 
Javascript :: function titleCase 
Javascript :: PostManDocs 
Javascript :: mongodb instructions 
Javascript :: discord.js sync channel permissions 
Javascript :: computed properties in react 
Javascript :: java scrypt 
Javascript :: inline css in react js 
Javascript :: javascript array cheatsheet 
Javascript :: react color picker 
Javascript :: static in class javascript 
ADD CONTENT
Topic
Content
Source link
Name
7+9 =