How do I get the simplified block content as in regular logseq.table.version 1 of Advanced Queries in custom :view

Depends all on what you need of course!

So I think the important distinction to make here is that we are using clojurescript functions on top of datascript / datalog tuples.
Which is your query result really.

So to get back to this, you are looking for a query like this:

Query:

#+BEGIN_QUERY
{:title [:h4 "🎯 Tasks"]
 :query [:find (pull ?b [*])
  :where
   ; Add the criteria for which ?b you want to find here. I've added all tasks as an example.
   [?b :block/marker ?m]
   (not [(contains? #{"DONE" "CANCELED"} ?m)] )
 ]
 :result-transform (fn [result] 
   (sort-by ; Any sort field here.
     (juxt ; sort by multiple fields
       (fn [r] (get r :block/scheduled 99999999)) ; sort field 1, if no value use 99999999
       (fn [r] (get r :block/priority "X")) ; sort field 2, if no value use X
       (fn [r] (get r :block/deadline 99999999)) ; sort field 3, if no value use 99999999
       (fn [r] (get r :block/content)) ; sort field 4
     )
     (map (fn [m] ; make a new map based on the query result
       (update m :block/properties ; update the block properties
         (fn [u] (assoc u :status (get-in m [:block/marker] "-") :priority (get-in m [:block/priority] "-") ) ) ; associate the marker and priority attribute values, use - when no value is present
       )
     ) result)
   )
 )
 :breadcrumb-show? false
}
#+END_QUERY

If you want to be able to add this to different queries. You can add the result-transform in the config.edn.

Here’s what my config looks like as an example.

Which we can use as :result-transform :sort-by-list for example.

1 Like