Skip to content Skip to sidebar Skip to footer

Like Search Into Mongodb With Monk Library

I'm trying to do like search into mongodb with Javascript, but i havent yet figured it out how to do it. Any help is appreciated. I have a search parameter called 'search' at reque

Solution 1:

I'm not familiar with the monk library but if the parameter in that find is a MongoDB Query Document this is the syntax you are looking for:

var query = {
  name: {
    $regex: req.body.search,
    $options: 'i'//i: ignore case, m: multiline, etc
  }
};

collection.find(query, {}, function(e,docs){});

Chekcout MongoDB $regex Documentaiton.

Post a Comment for "Like Search Into Mongodb With Monk Library"