Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Mongoose search multiple fields

var re = new RegExp(req.params.search, 'i');

app.User.find().or([{ 'firstName': { $regex: re }}, { 'lastName': { $regex: re }}]).sort('title', 1).exec(function(err, users) {
    res.json(JSON.stringify(users));
});
Source by www.semicolonworld.com #
 
PREVIOUS NEXT
Tagged: #Mongoose #search #multiple #fields
ADD COMMENT
Topic
Name
7+1 =