This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-09-09
Channels
- # aws (1)
- # babashka (61)
- # bangalore-clj (5)
- # beginners (83)
- # biff (2)
- # calva (4)
- # cider (6)
- # clara (5)
- # clj-kondo (72)
- # cljs-dev (31)
- # cljsrn (28)
- # clojure (8)
- # clojure-australia (1)
- # clojure-europe (19)
- # clojure-france (1)
- # clojure-losangeles (21)
- # clojure-nl (2)
- # clojure-spec (2)
- # clojure-uk (9)
- # clojurescript (13)
- # clojureverse-ops (5)
- # code-reviews (1)
- # conjure (7)
- # cursive (4)
- # datascript (2)
- # datomic (8)
- # depstar (1)
- # emacs (3)
- # etaoin (1)
- # events (3)
- # exercism (7)
- # fulcro (6)
- # girouette (2)
- # graalvm (125)
- # honeysql (17)
- # integrant (1)
- # jobs (12)
- # lsp (1)
- # numerical-computing (1)
- # off-topic (21)
- # portal (12)
- # practicalli (1)
- # re-frame (35)
- # reitit (5)
- # releases (1)
- # remote-jobs (1)
- # shadow-cljs (51)
- # tools-deps (14)
- # vim (3)
- # xtdb (20)
I'll rephrase my question from yesterday: how do you know who deleted a document (which user)? there isn't a tx metadata afaict, should you just replace the doc with a new version that contains only information about the deletion instead of deleting the doc
Ah yes, sorry to have missed replying to this! Busy day 🙂 Your suggestion certainly isn't bad. You could also model dedicated tx metadata entity(s) that work more generically, getting updated alongside each transaction
@U11SJ6Q0K that's what we're doing, we have a "transaction history" type object that stores the user, source microservice, transaction id, rationale, and a computed field-level diff
interesting, so do you store a tx history document along with each tx you do? does the tx history document link to the documents that were touched in the tx
In a datalog query is there a shorthand for getting the valid-time/as-of timestamp of the document as part of the query?
Hoping for something like this in my when arguments:
[['doc :crux.tx/tx-time tx-time]
`(<= ~start-timestamp tx-time)
`(<= tx-time ~end-timestamp)]
Alternatively, can I somehow join to the transaction log by transaction id and get the time of the transaction in results for post-query filtering?
Another useful alternative would be, given a crux node and a transaction id, get the transaction object with the timestamp
Hey @U0D5Y2403 there's nothing built-in for this, but you can pull in the tx data like this (using the magic $
var which denotes the db context)
(defn get-valid-time [db e]
(with-open [h (crux/open-entity-history db e :desc)]
(:crux.db/valid-time (first (iterator-seq h)))))
(crux/q (crux/db (crux-node))
'{:find [e vt]
:limit 1
:where [[e :crux.db/id]
[(my-ns/get-valid-time $ e) vt]]})
;;=> [[:bar #inst "2021-08-05T15:18:45.952-00:00"]]
(I had this pre-prepared here https://gist.github.com/refset/385d6dcfb66772aa1ec46fc20a49c633)Woof, I don't have the entity on-hand, I'm trying to query ALL transactions as of a timestamp and get the latest id given a date
but maybe the magic $ will do it
I think we'll just hit the postgres table directly with
SELECT max(event_offset) as max_tx_id, min(event_offset) as min_tx_id
FROM public.tx_events
where tx_time between '2021-09-03T21:27:16-00:00' and now()
ahh my bad, I was too focused on the initial message 😅
> Another useful alternative would be, given a crux node and a transaction id, get the transaction object with the timestamp
open-tx-log
essentially does this, if I understand correctly - or have you dismissed that already?
the only caveat to using open-tx-log
is that it doesn't use the node indexes, so it will hit the postgres table each time with something similar to the above anyway
interesting. If performance is an issue with open-tx-log I may go that route, but this is like 7ms currently
In https://xtdb.com/reference/1.19.0-beta1/queries.html#custom-functions it says
Be aware during development that query compilation internalizes function definitions and this means that subsequent re-definitions of your custom functions may not be reflected until the query is modified and therefore re-compiled.
What is the recommended way to work around this during development?