Delete the data from a table of a dating application

hi, does anyone have an example of how to delete the data from a table of a dating application, for example, I have an appointment for the day 01/03/2022
In March at 2:00 p.m., how can that data be deleted? If the appointment has already passed that day, it is no longer necessary to have it on the sheet. How can it be deleted automatically?

Thanks

Do you want to know how to delete it manually via your app, or do you want to know how to automatically delete it based on the date?

I’ve considered doing something like this in my app to clean up old data.

  • What I would do is create an IF column in the table with the dates. The IF column would check if the date is prior to Now. If it is, then return ‘true’ for a value.
  • Then I would pick a section of the app that is viewed often by users. In the table that drives that part of the app, I would first create a template column with the word ‘true’. Then I would create a single relation that links the template column to the IF column in whichever table contains the dates.
  • Now when a user clicks on a list item, for example, you can turn the action into a custom action that will first delete the dated row through the single relation, followed by going to the detail screen of the selected item.

The user will have no idea that they are the ones deleting the old rows. It’s not an automated process, but the more that a person uses the app, the more the old records will be deleted.

So, the trick is really to delete the row through a single relation, but make sure that the single relation only relates to rows with dates that have already passed.

I kind of do something similar in my calculator app. I have a rolling history table that keeps a history of the last 20 calculations that were done by the user. The table only ever has 20 rows. No more, no less. I have some logic in the history table that checks timestamps and ultimately marks the next row that should be updated. Then the calculator table has a single relation that links to only that row in the history table that’s marked as next, and that is the row that is updated when the user presses the equal button. It’s a little more complicated than you would need, but I think if you can mark the rows with some IF logic as the ones that need to be deleted, then a single relation to that marked row and a delete action that deletes through that relation should work for you.

8 Likes

yes, automatically delete it based on the date and hour?

That’s not possible without using something external to Glide.

But, have you read Jeffs response above :point_up:
That’s a really clever approach, and could easily be extended to hide the expired rows from view using filtering conditions. So the end result is that data would automatically be hidden from view at the appropriate time, and would eventually be permanently deleted.

2 Likes

@Jeff_Hager I decided to give this a try in my Custom Forms demo app. Because that one gets linked to a lot, it tends to accumulate quite a bit of “garbage data” as folks try it out. I used to periodically clean out junk rows, and then a few months ago I got sick of doing that, so I implemented a system where the original half dozen or so rows were kept “sticky”, and any new ones added would disappear after a day. That worked fine, but it didn’t stop the accumulation of garbage data - it just swept it under the carpet.

So I just quickly applied the technique you described here, and it seems to work like a charm. I’ve attached it to the Save new animal button, so now every time somebody creates a new record, an old one gets nuked.

I can foresee myself using this technique in quite a few apps moving forwards :wink:

1 Like

Awesome! Glad to hear it works. Why bother with scripting, or outside integrations when the user can unknowingly do all the work. :wink:

I’m planning to do something similar to clear out records that are over a year old in one of my tables. Or at least archive the old records into a separate table that’s not used for anything and doesn’t contain any additional computed columns. I think this would help with some speed issues I have with a table that’s been accumulating data for almost 3 years now, and is very heavy with computed columns.

2 Likes

Hi,I have been looking at your application I have seen that in actions you put it to delete the column but I see that it does not delete it. The rows of the year 2021 continue

That’s right, shouldn’t I delete it?

image


Thank

I tried it myself, and it’s working for me. It deletes a row as long as you submit a new animal row.

If I just checked it again and if you delete a row every time you add a data

@Jeff_Hager @Darren_Murphy
Nice trickery!

I was wondering, since you two seem to be developers in your day jobs: do developers also implement these types of “hacks” in their code? I ask because though I find your workaround really smart Jeff, I think it would pain me to do it :pray: :wink: I don’t know why, but I really dislike workarounds in general. Not practically, but conceptually.

Anyway, really nice technique to outsource clearing garbage data : )

1 Like

Maybe you don’t understand what it does.
It doesn’t delete any columns, it just deletes a single row - the first matching row that forms the single relation.

If you add an “animal”, you will notice that the total number of rows in the Animals table doesn’t change. That’s because every time one is added, one is also deleted.

1 Like

Hehe, programming is all about hacks and workarounds. Anything to make it work and get the job done…and still get a paycheck. :wink:

I mean, for something like this particular use case at my job, I would have access to run something like a scheduled nightly job to clean up the tables. Our whole system is internally built, so I have access to all the code, mainframe, servers, data, etc. Plus something, like calling a function that loops through and processes multiple rows of data, is very trivial.

Glide is different in that we have to work within the boundaries of the Glide system. Glide doesn’t really have a headless side to it that we can use to run code without any user interaction. In here, everything depends on user interaction one way or another. The only option we have within the glide world would be to use Google scripts or a third party service like Integromat. Whether or not you call these outside services a workaround, is up to you. I guess the less I have to rely on outside services to get the job done, the less points of failure if one of them goes down for any reason. For that reason, I try to achieve whatever I can strictly within glide.

Yes, you could consider my solution in this thread, as a workaround. I agree and wouldn’t consider it normal to execute a function like this by exploiting another function called by a user’s interaction with the app. A proper system would be an automated process that runs by itself. But Glide is meant to be a one size fits most solution that’s simple to use for most users. We don’t have access to all of the backend systems and code like a developer would. I think if they opened up that level of functionality, it would be much more confusing and overwhelming for the average user. I think Glide is trying to keep things simple, but some of us demand advanced functionality, so we have to come up with non-traditional methods to get it done.

At the end of the day, I think the word “workaround” can be interpreted loosely. Glide can’t reasonably build in all the functionality that can cover the thousands or millions of different use cases that everybody would have. That’s what the code world is for. We need to work with what we have at our disposal.

If I’m getting the results I need, I don’t really care how it’s achieved, as long as it works.

4 Likes

I don’t have a lot to add to what Jeff said, except to say that I violently agree with pretty much everything he did say.

I prefer to think of myself as a hacker rather than a professional developer. I’m mostly self-taught, and in general I know just enough to make myself really dangerous. I’m one of those guys that “real” developers hate - a tinkerer. I like to get in there and mess around under the hood. Sometimes I know what I’m doing, but most of the time I’m just winging it - learning and experimenting and making it up as I go along. I often mess things up, and I’m really good at breaking things. But I’ve also gotten pretty good at cleaning up my own mess, and sometimes even the messes made by others :wink:

Although I’m not a professional developer by trade, I’ve been closely involved with software development (and developers) for more than 20 years. And there is one common trait that I think all really good developers share. Which is their ability to think outside the box and come up with creative solutions to difficult problems. In some sense, this is how progress is made. Many things we now accept as standard “features” probably began their lives as “sneaky workarounds” :slight_smile:

2 Likes

Jeff, great idea!

1 Like

Rule number 1: listen to @Jeff_Hager

That’s it. No more rules.

5 Likes

:rofl:

Thank you very much for your help as you said glide is limited and very good since many users would not know how to use the programming your idea has helped me and it is functional thanks and a hug from Spain

1 Like

That’s beautiful :slightly_smiling_face:

2 Likes

I first started “coding” when I fiddled around in the early 90s with my parents’ PC, I would tinker with autoexec.bat and config.sys and create these really fun menus/journeys when the computer started. You cannot imagine how many sleepiness nights I spent fixing a computer that just would not boot anymore. Unlike you Darren, I never really became good at fixing my own mess, I got stuck on breaking things :joy:

4 Likes