Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

query middleware in express

//we will create secreteTour in schema and only send tour which are not secrete using query middleware
//query middleware run before .find() and .findOne()
tourSchema.pre(/^find,function(next) {
     this.find({secretTour: {$ne: true}})
     next()
})
 
PREVIOUS NEXT
Tagged: #query #middleware #express
ADD COMMENT
Topic
Name
1+2 =