Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

mongoose search in multiple fields

let regex = new RegExp(value.searchQuery,'i');
const filterd = await Model.find({ $and: [ { $or: [{title: regex },{description: regex}] }, {category: value.category}, {city:value.city} ] })
 
PREVIOUS NEXT
Tagged: #mongoose #search #multiple #fields
ADD COMMENT
Topic
Name
5+8 =