Reputation: 23301
I want to find a count of all documents with a title or desc field that contains my search string. I have tried the following and it always just returns all rows, ignoring the filter.
FCSet.count([{ 'title': { $regex: re }}, { 'desc': { $regex: re }}]).exec(function(err, count) {
}
I can do them one at a time, if I include just title it works just fine.
Upvotes: 0
Views: 75
Reputation: 19464
Try this:
FCSet.count(
{
$or: [
{ 'title': { $regex: re } },
{ 'desc': { $regex: re } }
]
}
).exec( function( err, count ) {}
Upvotes: 1