Hiding an Item in a Repeater after it Expires

I am trying to create a repeater that shows events in which people can sign up for, but I want the events to expire after their “endTime” has expired. Right now I have a “show” boolean value that if not checked, will hide all data. What I am trying to do is uncheck the “show” value, if today’s date is less than the “endTime” date. Here are screenshots of what I have so far:


If you cant see, the “Time Test” item should not show up since its “endTime” date is greater that today’s date, but it is still there. Please Help!

1 Like

Hey TJ,

This is how I would go about doing what you’re trying to do. It depends on how your connecting your repeater to data:

  • Connected to a dataset: use the setFilter function to filter the dataset to only have items with an endtime before the current date.

  • Data is set using the repeater’s data property: use the standard JavaScript array filter function to filter out items with an endtime after the current date from the array that you will use to set the data property.
    I don’t think you need to worry about a show boolean, unless you need it for some other purpose.

I was hoping to use the “show” boolean for organization in the database. I was hoping to be able to filter on the database side to what is currently being shown. Is there any way to make it change the show value?

You can definitely do that. The question is when you want to set it.

Looks to me from the code you have above that users don’t have permissions to update your collection. That’s why you’re trying to suppress the authorization. However, you can’t suppress the authorization in client-side code. You can only do that on the backend. Also, if you only send one property in the update object, the rest of the fields in you collection will be updated to be blank.

First I just want to say thank you for your help. How would I do it from the backend? Is there anyway to make the database update itself, like maybe once a day, or do I have to call the method from the client side?

The “simplest” way that I can currently think of to have the database update itself at some regular interval is to set up some 3rd party cron service to call a Wix Code HTTP function that you create to update the database.

You can read about HTTP functions here: Velo: Exposing a Site API with HTTP Functions | Help Center | Wix.com

I am not super familiar with the HTTP functions and am not sure how to use the GET POST PUT to achieve the result I am looking for. Would I need two separate functions, one a GET and one a PUT to accomplish my result, and would I need to call the PUT from the GET, or do I use a separate url?

You should be fine with just one. Since you are changing something in your collection, by convention you should use a PUT.

So I tried to create a function named updateDatabase and made the request but nothing happened. I have never used HTTP requests before to run my code, so can you help me figure out what I am missing. Here are the screenshots below and event after making the request, the database update like it should.