Checking if boolean in collection is true then...

Hiya all, I’m a total Wix Code newbie and was wondering if I could get some guidance.
As the title states I would like to check if a boolean value is true/false in my collection and if true it shows an image and false it stays hidden; Obviously the below is totally wrong but I’ve been trying for an hour or so with no further then when I started. Would appreciate any help! Would love to add in this little future in my back-end.
Code below thx!

wixData.query("profile")
  .eq("yardPr", "true")
  .find()
  .then( (results) => {
 let isHidden = $w("#10yPrIMG").hidden;  // false
 if( $w("#10yPrIMG").hidden ) {
  $w("#10yPrIMG").show();
}
else {
  $w("#10yPrIMG").hide();
}
  } )
  .catch( (error) => {
 let errorMsg = error.message;
 let code = error.code;
  } );

Try this:

wixData.query("profile")
  .eq("yardPr", true)
2 Likes

Oh man thx, it’s always the small things doh! Ok that part cleared up, it still doesn’t detect if the value is true or false unfortunately. I think my above code hard codes the boolean value to be true or false? Thx for your help.

Hi,
What field in the database saves the boolean value? you should use that in the if statement instead “$w(” #10yPrIMG “).hidden;”. I’d also recommend you to check out this articles about wix code basics.