Fork me on GitHub

do you have preferences on how to "type" documents? Do you add a type key or just rely on keysets between different document types being disjoint? I've come to like having maps with a single key as document ids. So instead of a random uuid as id, it is wrapped like {:company/id #uuid "..."} that way the "types" of documents are immediately obvious when navigating the db in xtdb inspector ui


that doesn't help with queries like "return all companies", but there I rely on them having a keyword not present in other document types

Steven Deobald10:02:48

@U11SJ6Q0K It would be great to have this thread on as I think this question comes up quite often. 🙂 Personally, I do both: {:type :company, :company/id #uuid "..."} ... this does allow me to do "return all companies" queries and the slight repetition doesn't seem to cause any issues. In terms of composable keys, it's less confusing than keys without namespaces, which I had originally started with.


I'll start a thread there


seems to already be there, should have checked before

Tomas Brejla11:02:32

@U01AVNG2XNF what's the benefit of having both :xt/id and :company/id, when you already have the type information in :type ?

Steven Deobald11:02:41

@U01LFP3LA6P I should know better than to answer a question like this at 6am. 😉 Sorry, :company/id is a bad example, in my case. I use :xt/id. But other attrs like :company/name I namespace with the type.

👍 1