It occurs to me that one could build a site/app with Bubble that, instead of treating the database as a persistent repository of (mostly) User-centered data, one could use the database as sort of a rolling cache of data that we regularly throw away.
The concept would be that more-or less all pages in your site have a data type – and only one data type. That data type would be called “Session” or something similar.
Pages with a type are typically expected to have the unique ID of the specific thing of that type as the last part of their path. For example, here’s a page on my own real-live app that has a type of “Listing”. When hit with the unique ID of a Listing, it shows a calendar of that Listing’s availability.
So, here’s that page with a valid Listing value:
^^^ The hilighted part of the URL is the unique ID of the Listing to which this calendar belongs.
If we hit this page without the Listing part of the path, the page essentially “breaks” as there is no data to feed the calendar – it’s just sort of a “shell”:
Of course, Bubble gives us the capability to detect this situation and do something if we should want to. In a workflow, we can do something like this: Detect if the thing is empty (the URL has been hit without the unique ID of a thing of the page’s type) and take action.
Typically this would be used to either redirect the user to some other page, or display a message that there’s nothing to see here, but we could do anything we want. Here’s how that works:
One “anything” would be to use this idea to assume that, if a page is hit without a Session object ID, the visitor must be in a new. They are not currently in a Session and we could create a Session object should they choose to continue.
As they change pages, we pass the Session object we created just for this “session” to other pages. We use the Session object to store anything that we need. If we’re on a paid plan, when we create the Session object, we can at the same time schedule it to be deleted at some future time (take your pick - some minutes, hours, or days from now) and all that object will go bye bye.
This is what I mean by using the database as a rolling cache.
So, in much the same way that you that folks lazily (or for lack of other knowledge) shove everything onto a User object, we would actually shove everything onto the Session object (or associate other objects with the Session object and also delete them when we delete the Session object).
I like this idea so much (even if it’s not super-useful) that I’m going to create a little demo app illustrating the principle.