I can not find the answer on google, as well as on mongoose, so I ask here. If possible, how can I find the partially matching line in the document.
ex:
In the user collection:
{ name: "Louis", location: "Paris, France" },
{ name: "Bill", location: "Paris, Illinoid" },
{ name: "Stephen", location: "Toronto, Ontario" }
Mongoose Function:
searchForCity("Paris");
The result will be a list of documents from the collection of users having “Paris” in the location String. eg:
[
{ name: "Louis", location: "Paris, France" },
{ name: "Homer", location: "Paris, Illinois" }
]
source
share