I am using the module "mongodb" to query mongodb from node js APIs. I am trying to search contacts document by a search query. The selector for the same is as below:
selector['users.name'] = {$regex: new RegExp(params.query), $options:"i"}
Consider the name of the user is "Sagar Gopale" and the search query is "sagar" or even "gopale" then the above works fine and returns results properly. But if I input search query as "sagar gopale" it returns empty result. Can someone provide me a solution so that I can input the search query including the space?
Thanks in advance.