This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-12-31
Channels
- # adventofcode (15)
- # announcements (3)
- # babashka (38)
- # beginners (121)
- # calva (29)
- # cider (21)
- # circleci (1)
- # clojure (177)
- # clojure-europe (7)
- # clojure-france (2)
- # clojure-nl (7)
- # clojure-spec (3)
- # clojure-switzerland (5)
- # clojure-uk (4)
- # clojurescript (10)
- # code-reviews (1)
- # conjure (19)
- # deps-new (2)
- # emacs (5)
- # fulcro (52)
- # graalvm (13)
- # kaocha (1)
- # malli (1)
- # off-topic (6)
- # pathom (5)
- # re-frame (17)
- # reagent (14)
- # remote-jobs (1)
- # rewrite-clj (5)
- # robots (1)
- # shadow-cljs (13)
- # sql (38)
- # tools-deps (16)
- # xtdb (99)
but get stuck here :
(easy-ingest node (crux/submit-tx
node
[[:crux.tx/put (1)
{:crux.db/id :consumer/RJ29sUU
:consumer-id :RJ29sUU
:first-name "Jay"
:last-name "Rose"
:cover? true
:cover-type :Full}
#inst "2113-12-03" ;; Valid time start
#inst "2114-12-03"] ;; Valid time end
[:crux.tx/put (2)
{:crux.db/id :consumer/RJ29sUU
:consumer-id :RJ29sUU
:first-name "Jay"
:last-name "Rose"
:cover? true
:cover-type :Full}
#inst "2112-12-03"
#inst "2113-12-03"]
[:crux.tx/put (3)
{:crux.db/id :consumer/RJ29sUU
:consumer-id :RJ29sUU
:first-name "Jay"
:last-name "Rose"
:cover? false}
#inst "2112-06-03"
#inst "2112-12-02"]
[:crux.tx/put (4)
{:crux.db/id :consumer/RJ29sUU
:consumer-id :RJ29sUU
:first-name "Jay"
:last-name "Rose"
:cover? true
:cover-type :Promotional}
#inst "2111-06-03"
#inst "2112-06-03"]]))
error message :
; Execution error (ClassCastException) at practicalli.earth/eval36748 (form-init8055691961700094689.clj:29).
; class java.lang.Long cannot be cast to class clojure.lang.IFn (java.lang.Long is in module java.base of loader 'bootstrap'; clojure.lang.IFn is in unnamed module of loader 'app')
; Execution error (ClassCastException) at practicalli.earth/eval36748 (form-init8055691961700094689.clj:29). ; class java.lang.Long cannot be cast to class clojure.lang.IFn (java.lang.Long is in module java.base of loader 'bootstrap'; clojure.lang.IFn is in unnamed module of loader 'app')
(1)
is invoking a number as a function
@j.antonelli712 thanks, I will try it but I cannot find that remark/comment
[:crux.tx/put '(3)
{:crux.db/id :consumer/RJ29sUU
:consumer-id :RJ29sUU
:first-name "Jay"
:last-name "Rose"
:cover? false}
#inst "2112-06-03"
#inst "2112-12-02"]
Hi @roelof! What Johanna was saying is that you should just delete those numbers in parenthesis because they are only used in the documentation as ‘footnote’ references :)
quote doesn't comment out, it just prevents evaluation. but those are not supposed to be there at all
chips. still errrors
; Execution error (ExceptionInfo) at crux.tx.conform/check-doc (conform.clj:16).
; invalid doc
(easy-ingest node (crux/submit-tx
node
[[:crux.tx/put
{:crux.db/id :consumer/RJ29sUU
:consumer-id :RJ29sUU
:first-name "Jay"
:last-name "Rose"
:cover? true
:cover-type :Full}
#inst "2113-12-03" ;; Valid time start
#inst "2114-12-03"] ;; Valid time end
[:crux.tx/put
{:crux.db/id :consumer/RJ29sUU
:consumer-id :RJ29sUU
:first-name "Jay"
:last-name "Rose"
:cover? true
:cover-type :Full}
#inst "2112-12-03"
#inst "2113-12-03"]
[:crux.tx/put
{:crux.db/id :consumer/RJ29sUU
:consumer-id :RJ29sUU
:first-name "Jay"
:last-name "Rose"
:cover? false}
#inst "2112-06-03"
#inst "2112-12-02"]
[:crux.tx/put
{:crux.db/id :consumer/RJ29sUU
:consumer-id :RJ29sUU
:first-name "Jay"
:last-name "Rose"
:cover? true
:cover-type :Promotional}
#inst "2111-06-03"
#inst "2112-06-03"]]))
(ns practicalli.earth
(:require [crux.api :as crux]))
(def node (crux/start-node {}))
(defn easy-ingest
"Uses Crux put transaction to add a vector of documents to a specified
node"
[node docs]
(crux/submit-tx node (mapv (fn [doc] [:crux.tx/put doc]) docs)))
(crux/submit-tx
node [[:crux.tx/put {:crux.db/id :kaarlang/clients
:clients [:encompass-trade]}
#inst "2110-01-01T09"
#inst "2111-01-01T09"]
[:crux.tx/put {:crux.db/id :kaarlang/clients
:clients [:encompass-trade :blue-energy]}
#inst "2111-01-01T09"
#inst "2113-01-01T09"]
[:crux.tx/put {:crux.db/id :kaarlang/clients
:clients [:blue-energy]}
#inst "2113-01-01T09"
#inst "2114-01-01T09"]
[:crux.tx/put {:crux.db/id :kaarlang/clients
:clients [:blue-energy :gold-harmony :tombaugh-resources]}
#inst "2114-01-01T09"
#inst "2115-01-01T09"]])
(crux/entity-history
(crux/db node #inst "2116-01-01T09")
:kaarlang/clients
:desc
{:with-docs? true})
That's interesting, the code above works fine in my emacs repl:
[{:crux.tx/tx-time #inst "2021-01-01T12:48:03.436-00:00",
:crux.tx/tx-id 0,
:crux.db/valid-time #inst "2115-01-01T09:00:00.000-00:00",
:crux.db/content-hash #crux/id "0000000000000000000000000000000000000000",
:crux.db/doc nil}
{:crux.tx/tx-time #inst "2021-01-01T12:48:03.436-00:00",
:crux.tx/tx-id 0,
:crux.db/valid-time #inst "2114-01-01T09:00:00.000-00:00",
:crux.db/content-hash #crux/id "d4bca6c78409d9d40ee42319a8aec32bffad9030",
:crux.db/doc
{:crux.db/id :kaarlang/clients,
:clients [:blue-energy :gold-harmony :tombaugh-resources]}}
{:crux.tx/tx-time #inst "2021-01-01T12:48:03.436-00:00",
:crux.tx/tx-id 0,
:crux.db/valid-time #inst "2113-01-01T09:00:00.000-00:00",
:crux.db/content-hash #crux/id "000e5b775b55d06f0bddc77d736184284aa1e4e9",
:crux.db/doc {:crux.db/id :kaarlang/clients, :clients [:blue-energy]}}
{:crux.tx/tx-time #inst "2021-01-01T12:48:03.436-00:00",
:crux.tx/tx-id 0,
:crux.db/valid-time #inst "2111-01-01T09:00:00.000-00:00",
:crux.db/content-hash #crux/id "cd71551fe21219db59067ce7483370fdebaae8b0",
:crux.db/doc
{:crux.db/id :kaarlang/clients, :clients [:encompass-trade :blue-energy]}}
{:crux.tx/tx-time #inst "2021-01-01T12:48:03.436-00:00",
:crux.tx/tx-id 0,
:crux.db/valid-time #inst "2110-01-01T09:00:00.000-00:00",
:crux.db/content-hash #crux/id "5ec42ea653288e01e1a9d7d2068b4658416177e0",
:crux.db/doc {:crux.db/id :kaarlang/clients, :clients [:encompass-trade]}}]
but this code seems to be hanging
(crux/entity-history
(crux/db node #inst "2116-01-01T09")
:kaarlang/clients
:desc
{:with-docs? true})
or can this be the culprit
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See for further details.
The code looks fine to me, so perhaps you're right and that error message is the culprit? Have you had a look at the URL to see if it gives a hint as to how to solve it?
and when I delete the desc part I see this error message :
; Execution error (IllegalArgumentException) at crux.history-options/<-sort-order (history_options.clj:5).
; No matching clause: {:with-docs? true}
[{:crux.tx/tx-time #inst "2021-01-01T14:06:03.679-00:00",
:crux.tx/tx-id 0,
:crux.db/valid-time #inst "2115-01-01T09:00:00.000-00:00",
:crux.db/content-hash #crux/id "0000000000000000000000000000000000000000"}
{:crux.tx/tx-time #inst "2021-01-01T14:06:51.917-00:00",
:crux.tx/tx-id 1,
:crux.db/valid-time #inst "2114-01-01T09:00:00.000-00:00",
:crux.db/content-hash #crux/id "d4bca6c78409d9d40ee42319a8aec32bffad9030"}
{:crux.tx/tx-time #inst "2021-01-01T14:06:51.917-00:00",
:crux.tx/tx-id 1,
:crux.db/valid-time #inst "2113-01-01T09:00:00.000-00:00",
:crux.db/content-hash #crux/id "000e5b775b55d06f0bddc77d736184284aa1e4e9"}
{:crux.tx/tx-time #inst "2021-01-01T14:06:51.917-00:00",
:crux.tx/tx-id 1,
:crux.db/valid-time #inst "2111-01-01T09:00:00.000-00:00",
:crux.db/content-hash #crux/id "cd71551fe21219db59067ce7483370fdebaae8b0"}
{:crux.tx/tx-time #inst "2021-01-01T14:06:51.917-00:00",
:crux.tx/tx-id 1,
:crux.db/valid-time #inst "2110-01-01T09:00:00.000-00:00",
:crux.db/content-hash #crux/id "5ec42ea653288e01e1a9d7d2068b4658416177e0"}]
clj::practicalli.earth=>
We are storing the data in memory here, every time you restart your repl you'll have to put it back in. If you've not intentionally restarted the repl it might be a hint as to where the problem lies. I'm not familiar with vs code but let me see if I can replicate there otherwise I can't be of much help to you (my emacs is happily playing nicely)
Unfortunately it's working fine in my vs code too, so it could be an issue with your setup:
I ran that in this project: https://github.com/johantonelli/tutorials
The blog should be fine too, this is the code use in the blog with some extra fluff I was playing with. It might be useful to debug for you - it should be up to date.
Another useful sanity check is the nextJournal versions https://nextjournal.com/crux-tutorial
You can edit / remix the posts and run each tutorial page, it spins up some clojure and actually runs so it's useful to know if it's a bug in the tutorial or something else
> oke, so the code can be found on the github Unofficially. That one might not be as up to date at all times because I'm lazy with pushing local changes
when reading the data I see this :
clj꞉tutorials.crux.jupiter꞉>
#:crux.tx{:tx-id 0, :tx-time #inst "2021-01-01T14:44:27.567-00:00"}
clojure -Sdeps '{:deps {nrepl/nrepl {:mvn/version "0.8.3"} cider/cider-nrepl {:mvn/version "0.25.5"} clj-kondo/clj-kondo {:mvn/version "2020.04.05"}}}' -m nrepl.cmdline --middleware "[cider.nrepl/cider-middleware]"
/bin/sh: 1: clojure: not found
Jack-in process exited. Status: 127
@taylor.jeremydavid Is the crux tutorial on GitHub? It might be good to comment out those “footnotes” directly in the code so new folks can copy/paste… or it’s likely this won’t be the first time this channel see this question. 😉