Hey all,
I wish to show a repeater contains only users who marked their profiles as ACTIVE.
Here’s the code I’m currently using, which works (shows ALL profiles, randomly) but ignores the ‘inActive’ filed (whith is a true\false field).
wixData.query(“Profiles”)
.find()
.then((result) => {
const shuffledArray = shuffleArray(result.items);
//add the shuffled array data to then repeaters
$w(‘#repeater2’).data = shuffledArray;
})
. catch ((err) => {
let errorMsg = err;
});
});
//random array index
function getRandomIndex(min, max) {
return Math.round(Math.random() * (max - min) + min);
}
//shuffle array data
function shuffleArray(dataArray){
for(let i = dataArray.length - 1; i > 0; i–){
let index = getRandomIndex(0, i);
const temp = dataArray[i];
dataArray[i] = dataArray[index];
dataArray[index] = temp;
}
return dataArray;
}