Fork me on GitHub

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

        :find (pull ?block-found [*])
        :in $ ?lower-case ?block-string-includes
        [?block-found :block/string ?block-string]
        [(?lower-case ?block-string) ?lower-block-string]
        [(clojure.string/includes? ?lower-block-string ?block-string-includes)]
Here’s the list of built ins


@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.

👍 3

@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.

👍 3

It works for roam/render. for js I think you’d have to write a toLowerCase function and pass that in, but haven’t tested passing function in in js yet

👍 3