I’m trying to use the hasSome() query function to find items in a database that contain one of an array of values.
However the hasSome() function only returns items whose specified field value is equal to a value in the array.
So, for example, say I have a database called “Dresses” and a field in that database called “Colour”. Now I’m using multi-selection radio buttons to allow the user to select which colour dresses they want to see. Say they want to see “black” and/or “yellow” dresses.
Now if this is my code:
colourArray = $w(“#colourRadiobuttons”)
// so in this example the value for colourArray[0] would become “black” and for colourArray[1] it //would become “yellow”
wixData.query(“Dresses”)
.hasSome(“colour”, colourArray)
This code will find items whose colour field is equal to black or yellow. But I need it to find items whose colour fields contain black or yellow - as I have some items that are multi coloured and so the value in their colour field could be “Black and White” for instance, and I would still want this item to be returned to the user when they search for “black” items.
So my question is - is there a way to find items in a database whose specified field value contains at least one item in an array?
Any help would much appreciated