Question: I have a problem when i query using mongoose.I coding follow this [Mongoose.js: Find user by username LIKE value](https://stackoverflow.com/questions/9824010/mongoose-js-find-user-by-username-like-value). But it return blank.

This my code return blank.

```
 var promise = UserSchema.find({name: /req.params.keyword/ }).limit(5);

```

I tried this return blank seem.

`var n = john; var promise = UserSchema.find({name: /n/ }).limit(5);`

But i tried this is working

```
 var promise = UserSchema.find({name: /john/ }).limit(5);

```

Why I use variable then return blank?

Answer: 
This is how i have done it to find if search string present in name/email.
Hope it helps someone.

```js
const getPeerSuggestions = async (req, res, next) => {

  const { search } = req.query;
  const rgx = (pattern) => new RegExp(`.*${pattern}.*`);
  const searchRgx = rgx(search);

  const peers = await User.find({
    $or: [
      { name: { $regex: searchRgx, $options: "i" } },
      { email: { $regex: searchRgx, $options: "i" } },
    ],
  })
    .limit(5)
    .catch(next);

  res.json(peers);
};

```
You can run a regex lookup with dynamic values using `RegExp`:

```js
 var promise = UserSchema.find({name: new RegExp(req.params.keyword, 'i') }).limit(5);

```

Notice the `'i'` option for case insensitivity.