Case-sensitive filter

Just created my first coding (That works! yay) to filter a dataset. However the ‘search/filter’ seems to be case-sensitive. Is there a way to make this non case sensitive?

import wixData from ‘wix-data’ ;

$w . onReady (() => {
$w ( ‘#searchBarInput’ ). onInput (() => filterDataset ());
$w ( ‘#sortDropdown’ ). onChange (() => filterDataset ());
})

function filterDataset () {
let filter = wixData . filter ();
let sort = wixData . sort ();
let searchValue = $w ( ‘#searchBarInput’ ). value ;
let sortValue = $w ( ‘#sortDropdown’ ). value ;

if ( searchValue . length > 0 ) { filter = filter . contains ( ‘artist’ , searchValue ). or ( filter . eq ( ‘title’ , searchValue )) }

switch ( sortValue ) {

case ‘a-z’ :
// Sort the products by their name: A - Z
sort = sort . ascending ( ‘artist’ );
break ;

case ‘z-a’ :
// Sort the products by their name: Z - A
sort = sort . descending ( ‘artist’ );
break ;

case ‘titleAse’ :
// Sort products by their price: Low - High
sort = sort . ascending ( ‘title’ );
break ;

case ‘titleDse’ :
// Sort products by their price: High to Low
sort = sort . descending ( ‘title’ );
break ;
}

$w ( '#dataset1' ). setFilter ( filter ). then (() =>  $w ( '#dataset1' ). setSort ( sort )); 

}

Thanks in advance
Danny😊

It looks like you have part of it right, this part is not case sensitive:

filter.contains('artist', searchValue)

The documentation for contains states, Matching with contains() is not case sensitive, so “text” does contain “Tex”.

The other part however is case sensitive:

filter.eq('title', searchValue)

The documentation for eq states, Matching strings with eq() is case sensitive, so “text” is not equal to “Text”.

Bummer. But all is not lost. You might be able to use contains() for that filter as well. Try it and see if that works for you.

The other option would be to do a non-filtered query, and then filter for your case-insensitive conditions in memory using Javascript.

Yisrael you are my hero ! Works like a dream - once you see it it’s obvious :sunglasses: