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 ;
});