How to filter repeater items?

Hi,
I have a database with all my items listed.
In the database, I added 2 boolean fields, one named “X” and one named “Y”.
Whenever an item from the list falls in the X category, I check the boolean box in the “X” field.
Whenever an item falls in the Y category, I check the boolean box in the “Y” field… I hope you get the idea.

I am now successfully displaying a repeater that randomly shows 5 items from the full list.
I’d like the repeater to only query items from the “X” category: basically, all items where the “X” boolean box is ticked.
How do I do that?

Here’s my code, thanks in advance!

let max = 29 ;
let skip = Math . floor ( Math . random () * max ) + 1 ;

wixData . query ( “allitems-qxb” )
. skip ( skip )
. limit ( 5 )
. find ()
. then (( results ) => {
let items = results . items ;

        **let**  itemData  = [{ 
                "_id" :  items [ 0 ]. _id , 
                "text1" :  items [ 0 ]. title , 
                "image1" :  items [ 0 ]. thumbnail 
            }, 
            { 
                "_id" :  items [ 1 ]. _id , 
                "text1" :  items [ 1 ]. title , 
                "image1" :  items [ 1 ]. thumbnail 
            }, 
            { 
                "_id" :  items [ 2 ]. _id , 
                "text1" :  items [ 2 ]. title , 
                "image1" :  items [ 2 ]. thumbnail 
            }, 
            { 
                "_id" :  items [ 3 ]. _id , 
                "text1" :  items [ 3 ]. title , 
                "image1" :  items [ 3 ]. thumbnail 
            }, 
            { 
                "_id" :  items [ 4 ]. _id , 
                "text1" :  items [ 4 ]. title , 
                "image1" :  items [ 4 ]. thumbnail 
            } 
        ]; 

        $w ( "#repeater3" ). data  =  itemData ; 
    }) 
    . **catch** (( error ) => { 
        **let**  errorMsg  =  error . message ; 
        **let**  code  =  error . code ; 
    });
// ----- USER-INTERFACE -------------------
var DATABASE = "allitems-qxb";
var DATAFIELD = "x";
var VALUE = true;
var max = 29;
// ----- USER-INTERFACE -------------------

$w.onReady(function() {
    let skip = Math.floor(Math.random() * max) + 1;
    wixData.query(DATABASE)
    .skip(skip)
    .limit(5)
    .eq(DATAFIELD, VALUE)
    .find()
    .then((results) => {
        let items = results.items;
        let itemData = [{
                "_id": items[0]._id,
                "text1": items[0].title,
                "image1": items[0].thumbnail
            },
            {
                "_id": items[1]._id,
                "text1": items[1].title,
                "image1": items[1].thumbnail
            },
            {
                "_id": items[2]._id,
                "text1": items[2].title,
                "image1": items[2].thumbnail
            },
            {
                "_id": items[3]._id,
                "text1": items[3].title,
                "image1": items[3].thumbnail
            },
            {
                "_id": items[4]._id,
                "text1": items[4].title,
                "image1": items[4].thumbnail
            }
        ];
        $w("#repeater3").data = itemData;
    }).catch((error) => {
        let errorMsg = error.message; console.log(errorMsg);
        let code = error.code; console.log(code);
    });
});

Thank you, that was exactly what I needed!
Everything works fine but It looks like that the code won’t work on mobile. It only works when accessing the site on desktop. Any idea why?

Sorry, i do not work on mobile pages, because a lot of functionalities and functions do not work in mobile-mode, which do work well on desktop.
Probably you will have to find another workaround to get your mobile-version working.

Probably you will have to write two different codes for each format. Yu can use this …

https://www.wix.com/velo/reference/wix-window/formfactor

…to detect the right device your code currently running at.