setFilter issue and help filtering numbers

Hi, I’m trying to filter results in a table based on a text input. One text box matched a name with the name column in my database, but I also want to be able to search via member number. I tried simply changing the name search to member number with no luck. I have now tried to connect the table to the dataset then filter by member number but get an error. The two situations are listed below.

//input2 is a text input box with number value
//‘membernumber’ is a database column of numbers
//I’ve tried with and without toString(), thought I had a casting issue
//function returns a blank table
export function button2_onClick(event){
let searchNumber = $w(‘#input2’).value;
wixData.query(‘SeriesDemo’)
.contains(‘membernumber’, searchNumber.toString())
.find()
.then(res =>
{
$w(‘#table1’).rows = res.items;
});

//alternative attempt I connected the database to the table and tried to filter with…
export function button2_onClick(event){
let searchNumber = $w(‘#input2’).value;
$w(“#SeriesDemo Dataset”).setFilter(wixData.filter()
.hasAll(searchNumber)
);
}
For this one I receive the error TypeError: $w(…).setFilter is not a function

Any help is appreciated!

Hey Luke,

A couple of things I see without digging too deep:

  1. What is the type of the member number field in your collection? Make sure you’re querying with the same type of data. Also, is there a reason you’re not using the .eq() function?

  2. The error you get when trying the second approach is almost certainly because you are using the dataset name and not it’s ID. Check the properties panel to get the correct ID.

  1. I’m using the eq() function now had missed it before. Also needed to use parseInt($w(‘#input1’).value, 10); to get the input from a string to int.

  2. That was the problem thanks!

how do i query on two separate input fields with an and condition using setfilter e.g. email and password
or does this need dataquery…please can you give me a sample code