.hasSome Query not finding results

Hi everyone

I keep coming up stumped on this one.

I’m trying to use the .hasSome query function. I’m wanting to see if any part of a string appears in the field searched using .hasSome . It’s my understanding I need to convert the string to an array, but I can’t seem to make it work properly.

The string is generated when people check/uncheck boxes

Then I just delete the last character of the string using string.length - 1 (this creates my string)

The populated string reads: “blue”, “green”, “yellow”

	
	
	var str = "blue", "green", "yellow";
	var array2 = [];
    	array2.push(str)
	
	wixData.query("NameOfData")
		.hasSome("field", array2)
		.find()
		.then((results) => {

		...
		

Could someone please nudge me in the right direction?

Many thanks!

Thomas

nudge

Hi Thomas,

You should be seeing an error in in the Corvid editor since you can’t declare a string variable in that way.
However, you can skip the step of trying to declare the str variable and do the following:

var array2 = [];
array2.push("blue", "green", "yellow")

Or … declare str as an array (with the brackets around it) and use push to add those items to the other array:

var str = ["blue", "green", "yellow"];
var array2 = [];
 array2.push(str)