Fork me on GitHub
#xtdb
<
2023-12-27
>
jwind12:12:18

EDIT, needed to use :in to perform the matching. Disregard. Thanks team 🙂

(defn new-download [version filename]
  (xt/submit-tx xtdb-node [[::xt/put
                            {:xt/id version
                             :driver/version version
                             :driver/filename filename}]]))

(defn download-version [version]
  (xt/q (xt/db xtdb-node) '{:find [e]
                            :where [[e :driver/version version]]}))
I have a noob question, I'm following the tutorial and my find query is seemingly returning everything rather than the one document with the exact match to my query...
obs.db> (new-download "1.2.3" "filename")
;; => #:xtdb.api{:tx-id 1, :tx-time #inst "2023-12-27T12:07:19.554-00:00"}
obs.db> (download-version "1.2.3")
;; => #{["1.2.3"]}
obs.db> (new-download "4.5.6" "filename")
;; => #:xtdb.api{:tx-id 2, :tx-time #inst "2023-12-27T12:07:44.605-00:00"}
obs.db> (download-version "1.2.3")
;; => #{["1.2.3"] ["4.5.6"]}
obs.db>
I know I'm more than likely doing something wrong, but can someone point me in the right direction?

jwind12:12:07

Nevermind, I had to utilize the :in clause, I thought I could enclose the query with the value that I needed but I think because it's implemented with macros that's not possible

refset18:12:24

Hey, thanks for following up with your own answer here 🙂 to clarify you can do all kinds of things to work around the quoting (`assoc`, the backtick library etc.) but :in is usually the right choice, yep 👍

jwind12:12:28

How should I think about structuring data with XTDB? I come from a traditional databases background. Would the idea be that related data should be grouped via the qualified keywords? For example, would a document representing a user likely contain mostly keywords like this: :user/username, etc.?

tatut14:12:48

“it depends”… it feels cleaner to model namespaced keywords usually imo

1
tatut14:12:35

but if you want to do things like search by :name from any entity type, then you could have the same name attribute

1
refset18:12:32

Cool, hope you found it interesting!

Daniel Craig21:12:20

It’s a great presentation, my use case is about times that get delayed and thinking about bitemporality on a graph database of departure and arrival times is bending my brain a little bit

🙂 1
refset17:12:26

I bet! I would be very curious to chat & learn more sometime in the new year :)