Adding dropdown filter to searchbox

I just got the code figured out to allow users to search a database of job applications so that it kicks back the results to a string of repeaters. Now I need to be able to add a dropdown to tie this to the searchbox. Most of the options I have seen involved or statements, but I require an and statement, if that exists. I would like to have my results shown by filtering by city, and then searching by keyword. Code for the search looks like this:

import wixData from ‘wix-data’;

export function button1_click(event, $w) {
//Add your code for this event here:
wixData.query(‘Applications’)
.contains(‘name’, $w(‘#searchbox’).value)
.or(wixData.query(‘Applications’)
.contains(‘position’, $w(‘#searchbox’).value))
.or(wixData.query(‘Applications’)
.contains(‘fullPartTime’, $w(‘#searchbox’).value))
.or(wixData.query(‘Applications’)
.contains(‘employer1’, $w(‘#searchbox’).value))
.or(wixData.query(‘Applications’)
.contains(‘employer2’, $w(‘#searchbox’).value))
.or(wixData.query(‘Applications’)
.contains(‘employer3’, $w(‘#searchbox’).value))
.or(wixData.query(‘Applications’)
.contains(‘position1’, $w(‘#searchbox’).value))
.or(wixData.query(‘Applications’)
.contains(‘position2’, $w(‘#searchbox’).value))
.or(wixData.query(‘Applications’)
.contains(‘position3’, $w(‘#searchbox’).value))
.or(wixData.query(‘Applications’)
.contains(‘languages’, $w(‘#searchbox’).value))
.or(wixData.query(‘Applications’)
.contains(‘skills’, $w(‘#searchbox’).value))
.or(wixData.query(‘Applications’)
.contains(‘certifications’, $w(‘#searchbox’).value))
.or(wixData.query(‘Applications’)
.contains(‘interests’, $w(‘#searchbox’).value))
.or(wixData.query(‘Applications’)
.contains(‘whatToOffer’, $w(‘#searchbox’).value))
.or(wixData.query(‘Applications’)
.contains(‘goals’, $w(‘#searchbox’).value))
.or(wixData.query(‘Applications’)
.contains(‘foodServed’, $w(‘#searchbox’).value))
.or(wixData.query(‘Applications’)
.contains(‘foodWantToServe’, $w(‘#searchbox’).value))
.or(wixData.query(‘Applications’)
.contains(‘sideoftown’, $w(‘#searchbox’).value))
.find()
.then(res => {
$w(‘#repeater2’).data = res.items;
$w(‘#repeater2’).show();
});
}

the dropdown would be considered #dropdown1

Hi Jared,

just add the condition at the end of the .or chain like so:

wixData.query('collection')
  .contains('field1', value1)
  .or(wixData.query().contains('field2', value2))
  .eq('field3', value3)
  .find()

The query is “field3 is equal to value 3 AND either field1 contains value 1 OR field2 contains value2”.

Bonus tip - specifing collection name in inner query (the one you pass to .or(…)) is optional.

I hope this helps. Let me know!