1

const UserSchema = new mongoose.Schema({ name: String, project_name: String });

const User = new mongoose.model("User", UserSchema);

<!DOCTYPE html>
<html lang="en" dir="ltr">
  <head>
    <meta charset="utf-8">
    <title>Search</title>
  </head>
  <body>
      <form  action="/" method="post">
          <input type="text" name="txt">
          <button type="submit" name="button" >Search</button>
      </form>
  </body>
</html>

i want that if a project name is "machine learning and oops" and i make a search in the search box for "oops", i should get "machine learning and oops" displayed

1 Answers1

1

You can use regex pattern to do fuzzy search like this.

User.find({project_name : /your-search-keyword-variable-here/}) 
Fahad Hassan
  • 781
  • 10
  • 20