How to query for a unique list of property values

Here is one way to do it:

#+BEGIN_QUERY
{:title [:h3 "Areas"]
 :query [:find ?areas
  :where
   [?b :block/properties ?props]
   [(get ?props :area) ?areas]
 ]
 :result-transform (fn [r]
   (def t (transient #{}))
   (doseq [set r]
     (doseq [item set]
       (conj! t item)
     )
   )
   (sort (vec (persistent! t)))
 )
 :view (fn [result] (for [r result]
   [:div [:a 
     {:href (str "#/page/" r)} 
     r
   ] ]
 ) )
}
#+END_QUERY
  • This assumes the usage of page references, through either:
    • double square brackets, e.g. [[area1]] [[area2]]
    • tags, e.g. #area1 #area2
    • :property/separated-by-commas , e.g. area1, area2