Give me all the areas/projects that I use to categorize pages

Hi,

In order to use a little of PARA organization, I tag some pages with properties like

area:: [[Health]]

or

project:: [[Kitchen Remodeling 2022]]

Now, I wanted to have a single page where I would list all projects and areas that I have used over my graph. I don’t want the pages tagged with a specific area/project. It’s the other way around.

I’ve managed to to that using this query (for the areas):

#+BEGIN_QUERY
{
 :title [:h4 "Areas"]
 :query [
         :find (pull ?p [*])
         :where 
         (has-page-property ?p :area)
         ]
 :result-transform (fn [result]
                     (distinct (mapcat (fn [linked-page]
                                         (get-in linked-page [:block/properties :area])
                                         ) result ))
                     )
 :view (fn [result]
         [:div.flex.flex-col
          (for [page result]
            [:a {:href (str "#/page/" page)} page ]
            )
          ]
         )
 }
#+END_QUERY

This query gives me this beautiful and useful list:

it took a while to figure out how to use :result-transform. Almost all the examples I saw just ordered the results, and never transformed the data within.

I hope this helps anyone having trouble using the advanced query. :slight_smile:

Thanks for the sharing!
Also bothered by lack of advanced queries documentation.
Do you have any idea if closure.core functions can be used in query? i experimented with select-keys, but failed to make it right. I find the select-keys from clojure.core - Clojure v1.11 API documentation

Hi Leo!

I’d assume select-keys would work as well. Perhaps you have the change :view a little bit? I only got my query working when I added the :view.

Thanks . I will try on this