TGViewer
Good dev knows Good dev knows @gooddevknows · 2K subscribers
Post #185 4.85K
❄️ Unique ids

We need ids to store the records and later refer to them. Numeric ids are good, but usually you do not want to expose them to the end customer because they can be enumerated. There are alternatives. Let's explore them.

* uuid. This is a standard, right? It's a default that everyone uses to generate a unique id. You can use this id and assume that no other machine or person in this universe will generate the same one. Example: 858e93a4-ff8d-11ed-be56-0242ac120002.

* nanoid. Small js (and not only) library, which generates short ids. Short ids and a small size are the benefits of this library over the "default" uuid/v4 that it generates shorter (you can even choose the length) ids and the size of the library is smaller. Example: zWSK7f4at3iI7TdMP-mYz.

* ulid. This one was new for me. It generates unique ids that are sortable in time. So when you have two of them, you can learn which was generated earlier. Basically, the timestamp is encoded there. Example: 01H1RF7HDAH1MY7E05S6MFC8QS.

⬛️ Do you know any other interesting approaches? Please, share.
  • 👍 33
More from @gooddevknows
  1. Aug 27, 2026🛰 Я придбав Starlink! Ще поза-вчора вранці я не збирався купляти ніякий Starlink. Але, пр…
  2. Jul 1, 2026photo post
  3. Jul 1, 2026✨ Crash Course: Storytelling для інженерів ✨ 📅 9 — 13 липня 2026 1️⃣ Чому історії працюют…
  4. Jul 1, 2026Post #278
  5. Apr 1, 2026We have one ticket left for: https://fwdays.com/event/tech-lead-course-5 . Code LIFE_BY_PP…
  6. Mar 9, 2026Hi friends, For those who have missed it, I now regularly post in my 🇺🇦 channel: https:/…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →