I’m having trouble targeting values in my dataset that are array type. I can get strings, numbers and booelans using the if (items[index].datasetValue === $w(“element”).value) in my code below. But I’m not sure how to mimic a .hasSome() for finding array type values, can anyone help?
Here is working code for strings and numbers
$w.onReady(async function () {
let results = await wixData.query('myDataCollection')
.limit(1000)
.find();
items = results.items;
}
export function fRepeater_itemReady($item, itemData, index) {
$item('#button1').onClick((event) => {
let number = $w("#dropdown2").value
let string = $w("#dropdown1").value
let uArray = [];
for (let index = 0; index < items.length; index++) {
if (items[index].numberCondition === number && items[index].stringCondition === string) {
let timeAvailable = items[index].timeSlot;
uArray.push(timeAvailable);
}
}
gen_list(uArray, $w('#dropdown3'));
})
}
Here is a not working function for an array type (returns a blank dropdown)
export function fRepeater_itemReady($item, itemData, index) {
$item('#button1').onClick((event) => {
dateString = `${itemData.data.monthName} ${itemData.day}, ${year}`;
dateObject = new Date(dateString)
let array = dateObject.getDay() // outputs the selected date as a 0-6 number representing days of the week
let string = $w("#dropdown1").value
let uArray = [];
for (let index = 0; index < items.length; index++) {
if (items[index].arrayCondition === array && items[index].stringCondition === string) {
let timeAvailable = items[index].timeSlot;
uArray.push(timeAvailable);
}
}
gen_list(uArray, $w('#dropdown3'));
})
}
I could convert my array types to numbers in the data collection but that would also involve me having to create hundreds more entries to account for fields containing more than 1 number… Not ideal.