Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

mongoose search combine fields

db.collection.aggregate([
  {
    $addFields: {
      nameFilter: {
        $concat: ["$name", " ", "$surname"],
      },
      locationFilter: {
        $concat: ["$workplace", " ", "$location"],
      },
    },
  },
  {
    $match: {
      nameFilter: {
        $regex: req.query.name,
        $options: "i",
      },
      locationFilter: {
        $regex: req.query.place,
        $options: "i",
      },
    },
  },
]);
Comment

PREVIOUS NEXT
Code Example
Javascript :: update karma jasmine to specific version 
Javascript :: backdrop issue with multiple modal 
Javascript :: javascript stringify blob 
Javascript :: jest mock implementation once 
Javascript :: Laravel react 404 routes 
Javascript :: nodejs module 
Javascript :: javascript diffence between a++ and ++a 
Javascript :: cogo toast 
Javascript :: window width onload jquery 
Javascript :: js insert in array 
Javascript :: convert c# to javascript online 
Javascript :: filepond remove file after upload 
Javascript :: convert string with dot or comma as decimal separator to number in javascript 
Javascript :: sidebar scroll css 
Javascript :: Delete - Cloudinary 
Javascript :: length of array 
Javascript :: how to take input n number in js 
Javascript :: what is express static 
Javascript :: detect scroll height 
Javascript :: array 
Javascript :: async await react stackoverflow 
Javascript :: convert json to 2d array 
Javascript :: how to change the text of a paragraph 
Javascript :: node js command line interface 
Javascript :: jq storage object on refresh 
Javascript :: indexof js 
Javascript :: run the for loop in the html elements and show the limited elements in javascript 
Javascript :: javascript find missing number 
Javascript :: if statemnt shorthand js without else 
Javascript :: javascript sorting an array 
ADD CONTENT
Topic
Content
Source link
Name
5+1 =