Want to create a search box in my app, using mongo as resource

I want to create a search box that will show me results from all matching documents/rows, I’ve only been able to show results for 1 document/row, I’ve tried using $or and creating multiple queries but neither work

Here’s what I’m currently using

{email: {"$regex": {{!textInput1.value ? {$exists: true}: textInput1.value}}, "$options": "i"}}

Hey @Patsy_Count!

It looks like you're on the right track here, testing that query on my end seems to work pretty well:

Would you mind sharing screenshots of your query and table settings? It seems like there may be something else here that's part of the issue :thinking:

Hi, I’m sorry if I wasn’t clear, but instead of just the search bar searching through the email row, I want it to search through ALL rows so that any match in any row shows up, be it country, language, email, name, etc

Ahh I see, you may have to specify each field you're searching. That's possible in an$or statement:

{
 $or:[
  {
     email: {
      "$regex": {{!textInput1.value ? {$exists: true}: textInput1.value}}, 
      "$options": "i"
     }
   },
   {
     name: {
      "$regex": {{!textInput1.value ? {$exists: true}: textInput1.value}}, 
      "$options": "i"
     }
   }
 ]
}

You can also dynamically generate the query for multiple fields with a transformer like:

const rowList = ["email", "name"];
const regexInput = {{!textInput1.value ? { $exists: true } : textInput1.value}};

return {
  $or: rowList.map((key) => ({
    [key]: {
      $regex: regexInput,
      $options: "i",
    },
  })),
};

Could either of those work?

The $or worked perfectly thank you!