show checked database on repeater


I want to show on my wix website similar like this…
services/amenities of residence/Appartement …so each and every residence provide different services so I need to show on website like this for repeaters depending on database information

is it possible to show only checked database services and hide unchecked database ?
I need help please

Yes this is surely possible.

  1. You will need a database.
  2. In this database, you will have a referencefield (boolean-function), where you will put all your options…
  3. Then you query this boolean-refField
import wixData from 'wix-data';

wixData.query("myCollection")
  .find()
  .then( (results) => {
    if(results.items.length > 0) {
      let firstItem = results.items[0]; //see item below
    } else {
      // handle case where no matching items found
    }
  } )
  .catch( (err) => {
    let errorMsg = err;
  } );

…and searches for the checked or unchecked values

.then( (results) => {
    if(results.items.length > 0) {
      let firstItem = results.items[0]; //see item below
      let items = results.items
      
      if (items[0].yourBooleanReffield === true) {console.log("boolean = true")}
      else {console.log("boolean = false")}
      
    } else {
      // handle case where no matching items found
    }
  } )
  1. Then you expand your CODE and put in some SHOW and HIDE-functions…
.then( (results) => {
    if(results.items.length > 0) {
      let firstItem = results.items[0]; //see item below
      let items = results.items
      
      if (items[0].yourBooleanReffield === true) {console.log("boolean = true")
        $w('#myElement1').show()
      }
      else {console.log("boolean = false")
        $w('#myElement1').hide()
      }
      
    } else {
      // handle case where no matching items found
    }
  } )
  1. Of course you will not have just one element, so you may need a loop…
    something like…
for (var i = 0; i < results.length; i++) {

}
  1. Put all together …
import wixData from 'wix-data';


  wixData.query("myCollection")
  .find()
  
  .then( (results) => {
    if(results.items.length > 0) {
      let firstItem = results.items[0]; //see item below
      let items = results.items
      
      for (var i = 0; i < results.length; i++) {
         if (items[i].yourBooleanReffield === true) {console.log("boolean = true")
           $w('#myElement'+i).show()
         }
         else {console.log("boolean = false")
           $w('#myElement'+i).hide()
         }
      }
      
    } else {
      // handle case where no matching items found
    }
  } )
  1. Do also not forget about the “onReady”-function ! ! !

This was just an brainstorming-example (not tested).

Good luck and happy coding!:wink: