This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-02-20
Channels
- # architecture (1)
- # babashka (5)
- # beginners (46)
- # calva (8)
- # cider (12)
- # clj-kondo (2)
- # cljfx (3)
- # clojure (23)
- # clojure-europe (7)
- # clojure-israel (2)
- # clojure-nl (11)
- # clojure-norway (8)
- # clojure-uk (1)
- # clojurescript (27)
- # conjure (2)
- # cursive (50)
- # data-oriented-programming (1)
- # data-science (1)
- # datahike (1)
- # datascript (12)
- # emacs (3)
- # events (1)
- # fulcro (13)
- # lambdaisland (7)
- # leiningen (4)
- # lsp (102)
- # meander (2)
- # off-topic (19)
- # parinfer (3)
- # reveal (8)
- # rewrite-clj (13)
- # shadow-cljs (3)
- # specter (13)
- # tools-deps (6)
- # vim (12)
Hi everyone! Thanks in advance for help with this datascript query I am trying to run with using string/lower-case within the WHERE clause. window.roamAlphaAPI.q(` [ :find (pull ?block-found [*]) :in $ ?block-string-includes :where [?block-found :block/string ?block-string] [(clojure.string/includes? (clojure.string/lower-case ?block-string) ?block-string-includes)] ] `, 'toggle'); This issue I am having is the following part where I try to turn the block strings to lower case before testing against the “toggle” string with string/includes? Thoughts? Thanks so much! [(clojure.string/includes? (clojure.string/lower-case ?block-string) ?block-string-includes)]
I don't have a repl handy, but I think you have to do it in two steps:
[
:find (pull ?block-found [*])
:in $ ?block-string-includes
:where [?block-found :block/string ?block-string]
[(clojure.string/lower-case ?block-string) ?lower-block-string]
[(clojure.string/includes? ?lower-block-string ?block-string-includes)]
]
get the lowercase string first and then call includes
Hmmm it’s not working but I’m wondering if the app I’m using does not have the lower-case function available because I’m getting a missing function error. Thanks for your quick help! I’ll try to figure out if that is true.
^^ datascript doesn’t have the lower-case fn by default, but you can pass it in
(d/q
'[
:find (pull ?block-found [*])
:in $ ?lower-case ?block-string-includes
:where
[?block-found :block/string ?block-string]
[(?lower-case ?block-string) ?lower-block-string]
[(clojure.string/includes? ?lower-block-string ?block-string-includes)]
]
@conn
clojure.string/lower-case
"toggle")
Here’s the list of built ins https://github.com/tonsky/datascript/blob/def78a2079230b2d58dd2555ab100a03233f3e49/src/datascript/query.cljc#L194@U018E92R0TY thanks! The app I am working on this for is pretty cool. You should try it ;) :rolling_on_the_floor_laughing:
@U015C84JNLQ what are you working on? I'm curious about the Roam extension ecosystem.
@U3X7174KS honestly this was just for building a simple wrapper for the read api so that I can have case insensitivity searches of all block that contain “xyz”
@U015C84JNLQ Nice. How are you using it? From inside your Roam graph? I haven't had the time to look into Roam extensibility, but I suspect I should.
You can do roam/js which allows you to run custom js straight from roam. I was just testing a query in chrome dev tools console.
@U018E92R0TY so that should work for {{roam/render}} right? But what I’m trying to do is with roam/js using the alpha api datascript queries. Am I able to pass other clojure functions in with the window.roamAlphaAPI.q
through roam/js? Thanks.