Combine multiple properties into one column in query table result

I have a page which lists all keyboards that I’m intrestedI Each keyboard is a block with various properties like (backlit, type, rating, url, price etc…)

the backlit property is a boolean - Yes/No
the type property is a single select - Bluetooth, Wired

Now, I want to query all the keyboards and list them in a table with their properties. But I want to combine backlit & type into a single column. Is this possible?


The query i’m currently using is below, which simply lists all column individually.

- {{query (and "⌨️" [[Electronics/Keyboards]])}}
  query-table:: true
  query-properties:: [:page :purchased-on :.image :type :url :backlit :price :rating]
1 Like

After some googling, I figured out how to do this:

#+BEGIN_QUERY
{:title "Query"
:query [:find (pull ?b [*])
       :where 
       [?b :block/content ?name]
       [(clojure.string/includes? ?name "⌨️")]]

:result-transform (fn [res] (map (fn [m] 
   (update m :block/properties 
   (fn [u] (assoc u :specs 
       (clojure.string/join "[:br]" [
           (apply str "Type: **" (get-in m [:block/properties :type]) "**")
           (apply str "Backlit: **" (get-in m [:block/properties :backlit]) "**")
       ]))
   ))
) res))
}
#+END_QUERY

this joins the type and backlit property into a column named “Specs”

2 Likes