This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-11-22
Channels
- # 100-days-of-code (1)
- # adventofcode (21)
- # announcements (2)
- # beginners (44)
- # calva (1)
- # cider (2)
- # cljdoc (16)
- # cljs-dev (70)
- # cljsrn (29)
- # clojure (66)
- # clojure-austria (1)
- # clojure-europe (4)
- # clojure-finland (1)
- # clojure-hamburg (1)
- # clojure-italy (24)
- # clojure-nl (3)
- # clojure-uk (127)
- # clojurescript (30)
- # core-typed (3)
- # cursive (34)
- # data-science (2)
- # datomic (16)
- # duct (17)
- # editors (1)
- # emacs (4)
- # figwheel-main (4)
- # fulcro (40)
- # hoplon (2)
- # instaparse (5)
- # kaocha (4)
- # leiningen (1)
- # luminus (4)
- # nrepl (46)
- # off-topic (5)
- # onyx (2)
- # other-languages (55)
- # parinfer (3)
- # protorepl (4)
- # re-frame (33)
- # reagent (6)
- # reitit (13)
- # ring-swagger (5)
- # shadow-cljs (26)
- # spacemacs (4)
- # sql (8)
- # testing (27)
- # tools-deps (21)
- # yada (1)
Beginner question: is it idiomatic to work directly with numeric entity-ids, e.g. in a URL like /user/:id
? I've seen example code where an attribute like :user/id
is used, but I'm not sure what the advantage of using such an attribute would be over the entity-id.
Strongly not recommended to expose entity ids externally (especially in a durable way).
There are various reasons in the evolution of your database which may cause you to renumber your entities, so don't rely on entity ids being stable.
Thanks v much for the help. So, If I'm going to create e.g. :user/id
, is there any support for generating those IDs?
You could use UUIDs, or if that's not suitable use or take inspiration from https://github.com/vvvvalvalval/datofu#generating-unique-readable-ids
UUID seems like overkill for something that only needs to be unique within this database
Overkill in what sense? UUIDs are essentially the least thought-consuming id generation strategy, it's the last thing I'd call overkill 🙂
Oh I see. Well, 128 bits of entropy, could be worse. I think Datomic has efficient storage and memory layouts for it. You could also represent it in text by encoding it in base64, this way you can represent it with 22-chars Strings, not that bad.
You can find much shorter for not-quite-uuids
@U09K620SG thanks for the pointer. However: > Many UUID generators produce data that is particularly difficult to index, which can cause performance issues creating indexes. To address this, Datomic includes a semi-sequential UUID generator (https://docs.datomic.com/on-prem/identity.html) I think I'll just accept the long URLs 🙂
Is squuid still a thing? I thought Datomic has since solved this with adaptive indexing