Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

in node.js with express how to remove the query string

import Tour from '../model/TourModel.js' 

function getAllTours= async(req,res)=> {
    //we cann't directly in variable cause it will refrence and not copy and delete of that variable delete that object
    const queryObj = { ...this.queryString };
    const excludedFields = ['page', 'sort', 'limit', 'fields'];
    //we use forEach cause we don't want to return the  array
    //
    excludedFields.forEach(el => delete queryObj[el]);
   const tours= await Tour.find({queryObj});
 }
 
Comment

PREVIOUS NEXT
Code Example
Javascript :: fields filtering in api from express 
Javascript :: How to limit properties of a JSON object given array of property names using JQ 
Javascript :: node-mongodb-native keep collection 
Javascript :: Node.js and Express session handling - Back button problem 
Javascript :: send data from a file to frontend nodejs 
Javascript :: to fix a broken class oop javascript 
Javascript :: react native communications 
Javascript :: Javascript array of array loop 
Javascript :: cleave js 
Javascript :: Clear for me API jquery 
Javascript :: in nav link if I click on the same active link, page has to refresh in react js 
Javascript :: javascript get next month name 
Javascript :: phaser wrap sprite 
Javascript :: generate package json for existing project 
Javascript :: ngrx angular Cannot add property 0, object is not extensible 
Javascript :: 1st element in underscore javascript 
Javascript :: empty or remove div span class 
Javascript :: how to display unicode in javascript 
Javascript :: give call suggestions while clicking on a contact number in next js 
Javascript :: Hardhat config file multiple network 
Javascript :: jQuery mobile anchor link on the same page 
Javascript :: useState intro 
Javascript :: Backbone Notes Miscellaneous 
Javascript :: Backbone + Express 
Javascript :: react private routes 
Javascript :: c# to javascript object 
Javascript :: jsdoc default value 
Javascript :: js 
Javascript :: fs.writefile promise 
Javascript :: array.map method 
ADD CONTENT
Topic
Content
Source link
Name
1+4 =