This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-10-30
Channels
- # aleph (4)
- # announcements (5)
- # architecture (1)
- # aws (5)
- # babashka (12)
- # beginners (143)
- # chlorine-clover (4)
- # cider (16)
- # clj-kondo (44)
- # cljfx (26)
- # cljsrn (2)
- # clojure (34)
- # clojure-europe (28)
- # clojure-gamedev (1)
- # clojure-nl (3)
- # clojure-provo (2)
- # clojure-spec (6)
- # clojure-uk (17)
- # clojurescript (99)
- # code-reviews (6)
- # core-async (15)
- # cryogen (9)
- # cursive (14)
- # data-science (1)
- # datomic (16)
- # duct (1)
- # events (4)
- # exercism (1)
- # figwheel-main (3)
- # fulcro (3)
- # hugsql (7)
- # leiningen (4)
- # malli (15)
- # off-topic (13)
- # pathom (8)
- # re-frame (7)
- # reitit (35)
- # remote-jobs (1)
- # sci (10)
- # shadow-cljs (32)
- # sql (5)
- # tools-deps (102)
- # tree-sitter (3)
- # uncomplicate (7)
- # vim (40)
- # xtdb (8)
hi there 🙂
I just updated https://github.com/jorinvo/crux-typescript-healthcare-demo/commit/b404a1600987b205fc5f4caf0cea522c4edf5923.
In general that worked pretty smooth.
The https://github.com/juxt/crux/blob/20.09-1.12.0/docs/topo-migration.adoc was super helpful, thanks for that!
One thing that confused me was, that the migration guide uses a backtick for module references.
Using that in crux.edn
gave me an error:
Execution error at crux.system/read-opts (system.clj:26).
Invalid leading character:
`
I https://www.opencrux.com/reference/20.09-1.12.1/rocksdb.html and they use a single quote. That gave me a different error:
Execution error (FileNotFoundException) at crux.system.ModuleRef/fn (system.clj:100).
Could not locate 'crux/rocksdb__init.class, 'crux/rocksdb.clj or 'crux/rocksdb.cljc on classpath.
What worked was to use the symbol directly. I guess both docs are not targeted at users of the crux.edn
file, but this took me a bit to figure out 😅hey @U8ZN5EHGU - glad to hear you got to the bottom of it
Ah, of course - yes, the values don't need to be quoted in crux.edn
because they're already quoted, essentially, by virtue of being EDN rather than Clojure. We'll have a think on how we can best represent this in the docs - thanks 🙂
one option would be to have a 3rd tab in the docs: JSON/Clojure/EDN.. not sure if that is too much to maintain 😄
I think a simple but prominent one-liner will be helpful - I too ran into this very initially (mentally not distinguishing between the sample, in-code config and what goes into some config.edn
), but soon figured out.
If you want to amend a document (such as UPDATE
in SQL), where you change only the value of one or more key/vals, but the rest of the document is kept, is that possible without first getting the whole of the document from crux, and then resubmitting the whole thing in a new transaction?
Explaination:
(crux.api/submit-tx node
[[:crux.tx/put {:crux.db/id :temp
:dont-change-me "yo"
:some-bool? false}]])
(crux.api/q (crux.api/db node)
{:find '[?id ?dont-change-me
?some-bool?]
:where '[[?id :crux.db/id :temp]
[?id :dont-change-me ?dont-change-me]
[?id :some-bool? ?some-bool?]]})
;; => #{[:temp "yo" true]}
And then I'll submit a transaction to update :some-bool?
but not to care about :dont-change-me
(crux.api/submit-tx node
[[:crux.tx/put {:crux.db/id :temp
;; :dont-change-me "yo"
:some-bool? true}]])
And let's have another look
(crux.api/q (crux.api/db node)
{:find '[?id ?dont-change-me
?some-bool?]
:where '[[?id :crux.db/id :temp]
[?id :dont-change-me ?dont-change-me]
[?id :some-bool? ?some-bool?]]})
;; => #{}
but rather
(crux.api/q (crux.api/db node)
{:find '[?id ;; ?dont-change-me
?some-bool?]
:where '[[?id :crux.db/id :temp]
;; [?id :dont-change-me ?dont-change-me]
[?id :some-bool? ?some-bool?]]})
;; => #{[:temp true]}
So that's my question. Can you update a document that is already existing, without removing all information kept in it but the field you wish you update?Hi 🙂 there's no native (core) API for doing an update/patch like this in Crux, although if you want to recreate those kinds of transactional semantics you can use a transaction function, e.g. https://gist.github.com/refset/a00be06443bc03ccc84a2874af3cdb8a#file-txfns-clj-L10-L31 - just be aware that it will still be resolved to documents under the hood. There was a recent thread about this that you may find interesting for more context https://clojurians-log.clojureverse.org/crux/2020-10-17/1602949393.166100
I guess in datomic it'd be called replace