store an array in database and filter by checkbox

Is there a way to store an array into database and filter it with multiple checkbox?

say I have a field called colors and will be storing an array or comma separated string. I want to set filter when a checkbox is clicked.

for instants my field value is ‘red, blue, yellow’

checkboxes are
red (checked)
green (unchecked)
blue (checked)
yellow (checked)

it should be able to return the result.

#dataset.setFilter().hasSome(“colors”, [‘red’,‘blue’,‘yellow’]) will not work
I need a better solution

Hi Bryan,

How about grouping your check boxes then in change for each one :

export function Redcheckbox_change(event, $w)
 {
 $w("#checkboxes").children.forEach((element,i)=> { //#checkboxes the checkboxes group id
 if(element.checked){ //true
      checked.push(element.value);
      console.log(checked);// red
    }
 
  })
}

Note that you can set the value of check box by clicking on the check box then set value, so that you can access it with element.value.

Good Luck.

Mustafa