Data after today delet

ok so i have a giveaway dataset that users put info in . this dataset has a row for “end date”
i want the data to get deleted once the end date has passed , is there a way to do this?

1 Like

Yes, there is. The Wix-Dataset has a Remove()-function. I would do it like this:

  1. build a page with the desired dataset and compare ‘end date’ to system date in your selection of rows to be deleted
  2. then use Remove() to delete the selected dataset

You would have to do this by hand, meaning that you have to fire the page every day. If you want to automate it, somebody here pointed me towards easycron.com , which lets you schedule the execution of any page, e.g. every 24 hours.

Should be from data, not dataset. Wix-data also has a remove function.

I would also use this and code a code after page is loaded that deletes records an if you dont have cash for easy cron use Free cronjobs - from minutely to once a year. - cron-job.org

Hi Francisco,
You got some great tips, just want to add my take on it - you may want to save these records for future auditing. You can add a column “Expired” with yes/no values, with the methods Giri and Andreas suggested.
With the data hooks advanced feature, you can even do cooler stuff - you can write a hook that on every query, automatically calculates if the giveaway expired, and add that to the returned results. You can even filter these rows out of the results, as if they were deleted. That way you write it once, and don’t need to maintain it.

Hi i just refound this thread lol XD , yes but i want my users to have the easiest possible experience… is there maybe a code where i could hide the post ?

@Tomer i think i would like to remove the post all together just to keep things nice and neat. there is no real use for it after the end date is up :slight_smile:
What i want to happen

on page load
end date < or = today’s date
Remove

Hey
Create a page and on that page create a dataset connected to the correct collection.

Then in code, set filter on dataset to only show records where date field < or = today.

Loop through the resulsts and delete records.

Setup a easycron job to execute this page on a schedule.

All code needed can easily be found here and in the API.

Can you give me an example of what the code may look like ?