This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-06-13
Channels
- # babashka (5)
- # beginners (52)
- # biff (11)
- # brompton (5)
- # calva (2)
- # cider (7)
- # clojure (80)
- # clojure-europe (3)
- # clojure-finland (1)
- # clojure-nl (3)
- # clojure-norway (1)
- # clojure-uk (3)
- # clojurescript (15)
- # conjure (4)
- # core-async (9)
- # cursive (3)
- # datahike (38)
- # datascript (1)
- # datomic (7)
- # duct (9)
- # emacs (4)
- # fulcro (11)
- # graalvm (21)
- # honeysql (5)
- # lambdaisland (1)
- # leiningen (1)
- # news-and-articles (1)
- # off-topic (8)
- # react (42)
- # reagent (6)
- # reitit (11)
- # shadow-cljs (62)
- # specter (1)
- # spire (2)
- # sql (1)
- # tools-deps (12)
- # vim (5)
@jrwdunham Neither of these indices is sorted by transaction time, if this is what you need. @konrad.kuehne Can we use one of the history indices for that?
Question.... is there a db.type for time?
Ah there is! instant 🙂 thnx
So I do a query on my database,
(println (d/q '[:find ?m
:where
[?m :message/kind "chatroom"]
[?m :message/title "Beginners"]]
@conn))
works great, returns a set
#{[Grammar] [Beginners] [Vocabulary] [にほんご] [Translation]}
But when I try to do an on-the-fly argument from a destructured compojure route, using (str room-name) instead of "Beginners" or something like that... I get no results.
(defn room-handler [room-key ring-req]
...
...
(if-let [rk-set
(d/q '[:find ?m
:where
[?m :message/kind "chatroom"]
[?m :message/title (str room-key)]]
@conn)]
(println "rk-set : " rk-set)
)
The invocation (str room-key) ... really room-name... does not give me any results ;x
So yeah, rather than hardcoding a string... how can I put a string variable in the query ?
hi @sova, would be something like this
(d/q '[:find ?m
:in $ ?room-name
:where
[?m :message/kind ?room-name]
[?m :message/title (str room-key)]]
@conn
"chatroom")
I might be wrong, but datahike follows the syntax of datascript, therefore there are tons of tutorials here https://github.com/kristianmandrup/datascript-tutorial
Right on.. Yeah no luck with that line quite yet
I thought something like that would work, but I still get an empty result set
thanks for the :in $ line... forgot about that from datomic land
but I am not sure what I'm missing now
looking at that piece that I pasted here, the room-key is kind of alien to that query, right?
When I print the result to console I get
#{[Grammar] [Beginners] [Vocabulary] [にほんご] [Translation]}
notably not in quotes... not a prob?room-key is bound earlier by something else
but I don't have the literal ... just a variable that should be equivalent
the literal works great, but the variable apparently not so... maybe i am missing something with what happens to this string
(println (d/q '[:find ?m
:in $ ?kind ?title
:where
[?m :message/kind ?kind]
[?m :message/title ?title]]
@conn
"chatroom"
"Beginners"))
Oh. that's awesome let me try that
@iagwanderson you're a genius!
two fives way in the air for ya, 5️⃣5️⃣
(println (d/q '[:find ?m
:in $ [?kind ?title]
:where
[?m :message/kind ?kind]
[?m :message/title ?title]]
@conn
["chatroom" "Beginners"]))
thanks very much
That helps a lot.