Quantcast
Channel: $or Operator in Mongoose - Stack Overflow
Viewing all articles
Browse latest Browse all 2

Answer by Đăng Khoa Đinh for $or Operator in Mongoose

$
0
0

I think the problem is because you wrap the regular expression in ``, which is understood as a string. You can try this way:

const queryWordRegex = new RegExp(body.queryWord, "i");const query = {$or: [  { name: { $regex: queryWordRegex  } },  { description: { $regex: queryWordRegex  } }, ],};

Viewing all articles
Browse latest Browse all 2

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>