This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-09-29
Channels
- # announcements (6)
- # babashka (23)
- # beginners (15)
- # biff (15)
- # calva (17)
- # clara (5)
- # clj-kondo (41)
- # cljdoc (2)
- # cljs-dev (67)
- # cljsrn (18)
- # clojure (19)
- # clojure-europe (25)
- # clojure-nl (2)
- # clojure-norway (9)
- # clojure-uk (2)
- # clojurescript (26)
- # core-typed (6)
- # cursive (15)
- # data-science (30)
- # datahike (1)
- # datomic (18)
- # docker (6)
- # emacs (10)
- # events (2)
- # graalvm (15)
- # graphql (5)
- # hugsql (4)
- # jobs-discuss (1)
- # joker (7)
- # lsp (36)
- # malli (28)
- # off-topic (46)
- # other-languages (1)
- # pathom (5)
- # pedestal (6)
- # polylith (5)
- # reitit (2)
- # releases (1)
- # rewrite-clj (63)
- # shadow-cljs (7)
- # spacemacs (16)
- # squint (6)
- # tools-deps (6)
- # xtdb (13)
Does xtdb return only one document if there are numerous ones with the same values (but different ids) by default? I have numerous test documents with the same values (all x y z for latin-name, common-name, img) with different random ids, and querying them only returns one…
(defn query []
(xt/q (xt/db dbnode)
'{:find [latin-name common-name image]
:where [[e :treefrog/img "z"]
[e :treefrog/img image]
[e :treefrog/latin-name latin-name]
[e :treefrog/common-name common-name]]}))
(PS - open to corrections on how I’m constructing my query, too! Here I’m trying to find all documents with the value for :treefrog/img of “z”)Yep these "set semantics" are intentional and really what Datalog is all about. If you want to see all the duplicates then you have to :find (and return) the ids also, otherwise the result tuples get deduplicated
aha ok, all’s well then. I suppose people prevent duplicate document creation, then, in software.

In the case of ‘same data, different time’ a timestamp would make sure one gets all the documents, I’m guessing.
Yep exactly, and there's an example of pulling out the timestamps here: https://docs.xtdb.com/language-reference/datalog-queries/#custom-functions
Hi! I'd be interested in hearing any migration strategies that people have found handy with XTDB. I would find it pretty trivial to just append migration logic to db-component startup, one function at a time with version checks (kind of an ad-hoc Liquibase specific to this project and baked into code...)
I wrote https://github.com/pariyatti/joplin.xtdb ... and shortly after realized it was a mistake. 😉 Largely, it doesn't even really handle "migration" so much as storing a schema which dictates writes into the db itself. It also restricts XTDB values to a set as closely resembling Datomic's as possible.
Since I'd describe migrations in XTDB as "mostly a mistake", I guess I'd jump back a step and ask: what's your desired outcome with migrations? Are you just hoping to keep a consistent schema across an entire timeline? And if you do, are you okay muddying the waters of what qualifies as "historical"?
Yes – good thoughts! I was going to add that the migrations I'm mostly talking are data migrations – I need to modify the existing database with new information and possibly make transformations to existing documents taking this new data into consideration.
Ah, interesting. Your current approach sounds sane, and not unlike the kinds of schema/data migrations I've seen in mobile apps for SQLite dbs. That said, if you wanted to extract a tool (however small) for data migrations over xtdb, I sincerely doubt you're the only one who's wondered this. 🙂
It feels like the bitemporal aspects bring another point to consider… do you want to migrate docs that “from now on, the docs look like this” or do you want migrate all histories “the docs have always looked like this”
changing the shape of your data means your code needs to know when the change happened, when you are querying in the past
Excellent point! What changes here are references to other documents – basically querying with proper valid times should make queries it consistent across time.