Quantcast
Viewing latest article 1
Browse Latest Browse All 2

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

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 latest article 1
Browse Latest Browse All 2

Trending Articles



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