Fork me on GitHub
#xtdb
<
2022-02-18
>
tatut05:02:46

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

tatut05:02:12

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 http://discuss.xtdb.com 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.

tatut10:02:26

I'll start a thread there

tatut10:02:33

seems to already be there, should have checked before https://discuss.xtdb.com/t/how-to-model-entity-type/37

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