mediafinger / yournaling

An app to journal, to link memories, photos, locations and combine them to a travel log
Other
0 stars 0 forks source link

Migrate custom tables to use YID instead of UUIDs #7

Closed mediafinger closed 1 year ago

mediafinger commented 1 year ago

Idea

Rather large change, to not use UUIDs for our custom tables, but YIDs (Yournaling IDs) that consist of three parts:

In this implementation the YIDs have to be generated on the server.

YID - Yournaling ID

YID are sortable unique IDs which contain:

YID are:

YID are constructed like this:

YID creation is slow compared to integer IDs or UUIDs, they are long and comparing them is more costly than comparing UUIDs. Their benefits are that they directly reveal the type of object (which is a massive bonus when debugging or sharing object identifiers) and that they are sortable at every moment, without additional database queries (which can speed up the app a lot).

Any YID can be fed to the search / an endpoint / a disolver service which can then return the actual object (or an error e.g. 403, 404, ...).

YID can be used in URLs, but as they are long and probably funny-looking, you might consider using slugs. The slug should be created by some fast symmetric encoding / decoding encryption algorithm that backends and frontends can use.