I have a mongoose model with schema defined as -
var campusNotesSchema = mongoose.Schema({
noteId:{type:String, unique:true, default: uuid.v4()},
ti
You can user $or operator in mongoose to return results with either of matches
$or http://docs.mongodb.org/manual/reference/operator/query/or/
Campusnotes.find({'$or':[{title:new RegExp(searchText,'i')},{description:new RegExp(searchText,'i')}]}).exec(function(err, collection) {
res.send(collection);
})
To search in array for matching strings, you need to use $in operator of mongo:
$in : http://docs.mongodb.org/manual/reference/operator/query/in/
use this query ,$option = i, will skip the lower /upper case when you are inserting data into TAG array first make it lowercase and search with lowercase this would be easy.
Campusnotes.find({title:{'$regex':searchText,'$option':'i'},description:{'$regex':searchText,'$option':'i'},tags:searchText}, function(err, collection){
res.send(collection);
});