I am trying to do a simple wildcard query in a MongoDB database using a user-generated string variable. For example, if the user searches 'Bu', things like 'Burger' and 'Burger King' should be returned from the database. I have searched and tried several things but nothing seems to work. Any help would be greatly appreciated. Note: This is client-side JS.
var text = document.getElementById("Search_Box").value;
var regex = new RegExp(text + ".*");
client.login().then(() => db.collection('businesses')
.find({name:{$regex:regex}}).then(docs => {
console.log("[MongoDB Stitch] Connected to Stitch");