Hi,
I would like to have this simple query as advanced query because I would like to include it into config.edn for my Journal page.
Could you please help? I don‘t find an example solution.
- {{query (and (AND (page-property type Projekt) (page-property area Arbeit)) (page-property :status "#inBearbeitung")) }}
query-sort-by:: page
query-table:: false
query-sort-desc:: false
query-properties:: [:icon :status :updated-at :page :start]
So technically it is not so difficult, however the config queries don’t support table output. That makes it complicated.
Making it an advanced query
{:title ["Pages"]
:query (and (AND (page-property type Projekt) (page-property area Arbeit)) (page-property :status "#inBearbeitung")) }
But for config.edn
{:title ["Pages"]
:query [:find ?name
:where
[?p :block/name ?name]
[?p :block/properties-text-values ?prop]
[(get ?prop :type) ?type]
[(get ?prop :area) ?area]
[(get ?prop :status) ?status]
[(= ?type "Projekt")]
[(= ?area "Arbeit")]
[(= ?status "#inBearbeitung")]
]
:view (fn [result] (for [r result] [:div [:a.tag.mr-1 {:href (str "#/page/" (clojure.string/replace r "/" "%2F") )} r ] ] ) )
}
1 Like
Great - thank you!
What my simply query does not show is that I use page links as property content. Due to them your example does not work for me:
[(= ?type "[[Projekt]]")]
[(= ?area "[[Arbeit]]")]
Any idea why?
No idea why honestly. However, here’s what the query should be in that situation:
{:title ["Pages"]
:query [:find ?name
:where
[?p :block/name ?name]
[?p :block/properties-text-values ?prop]
[(get ?prop :type) ?type]
[(get ?prop :area) ?area]
[(get ?prop :status) ?status]
[(contains? #{"[[Projekt]]"} ?type)]
[(contains? #{"[[Arbeit]]"} ?area)]
[(= ?status "#inBearbeitung")]
]
:view (fn [result] (for [r result] [:div [:a.tag.mr-1 {:href (str "#/page/" (clojure.string/replace r "/" "%2F") )} r ] ] ) )
}