Query for untagged blocks in journal page

hi,

i tried following code trying to query all untagged block in journal page, but fails…

#+BEGIN_QUERY
{:title [:h3 “query all untagged block in journal page”]
:query [:find (pull ?b [*])
:where
[?p :block/name _]
[?p :page/journal? true]
[?b :block/page ?p]
(not [(clojure.string/includes? ?b “#”)])
]}
#+END_QUERY

thank you for any hints

  • How exactly does it fail?
  • clojure.string/includes? needs a string to work with
    • ?b is not a string, but an id, representing a block
    • you may want to pass instead the content of that block, like this:
      [?b :block/content ?c]
      (not [(clojure.string/includes? ?c "#")])
      
1 Like

@mentaloid thank you very much, accordingly i update the code as follows:

#+BEGIN_QUERY
{:title [:h3 "random 3 untagged blocks from joural pages"]
 :query [:find (pull ?b [*])
         :where
         [?p :block/name _]
         [?p :page/journal? true]
         [?b :block/page ?p]
         [?b :block/content ?c]
         (not [(clojure.string/includes? ?c "#" )])
         (not [(clojure.string/includes? ?c "[[" )])
         ]
:result-transform (fn [result] (take 3 (shuffle result)))
:breadcrumb-show? true
:collapsed? true
}
#+END_QUERY

the code will resurface 3 untagged blocks from journal pages, basically it works for me so far so good

1 Like