I'm having trouble finding the correct code and how to insert it into this code I found . I have a dataset of all members and I want to filter it so that only current members display, but I also want to randomize the results.
I have this code below which randomizes all the members even if I have a filter set on the database to display current members only. I want to write the filter into the code to have current_members=Yes.
Could someone help me complete the code so that it will display only current members, yet be randomized? The current_members field = Yes
The current code also takes a while to process and before it does the listings are in alphabetical order, then change each time the page is refreshed.
Thanks.
// For full API documentation, including code examples, visit https://wix.to/94BuAAs import wixData from 'wix-data'; $w.onReady(function () { //get the collection records wixData.query("ppocc_members") .find() .then((result) => { const shuffledArray = shuffleArray(result.items); //add the shuffled array data to then repeaters $w('#repeater1').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; }