Skip to content

Instantly share code, notes, and snippets.

@refset
Created May 7, 2022 18:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save refset/65602bdbc4e75cb0d2047ff9ce0134a4 to your computer and use it in GitHub Desktop.
Save refset/65602bdbc4e75cb0d2047ff9ce0134a4 to your computer and use it in GitHub Desktop.
which-op-failed.clj
(def n (xt/start-node {}))
(xt/submit-tx n [[::xt/put {:xt/id :a :foo :bar}]])
(defn with-tx-failed? [db ops]
(nil? (xt/with-tx db ops)))
(xt/q (xt/db n (xt/latest-completed-tx n))
'{:find [ops]
:in [[ops ...]]
:where [[(dev/with-tx-failed? $ ops)]]}
[[[::xt/put {:xt/id :a :foo :bar}]]
[[::xt/match :b {:xt/id :b}] [::xt/put {:xt/id :b :foo :bar}]]
[[::xt/match :c nil] [::xt/put {:xt/id :c :foo :bar}]]])
;;=> #{[[[:xtdb.api/match :b #:xt{:id :b}] [:xtdb.api/put {:foo :bar, :xt/id :b}]]]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment