Fork me on GitHub

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


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 🙂


I guess I meant unnecessarily large, but I take your point.


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 ( I think I'll just accept the long URLs 🙂


Is squuid still a thing? I thought Datomic has since solved this with adaptive indexing


Hmm that could well be true. I have no idea


Found something similar at the same time. Thanks