Get page title only instead of blocks and sort by original order in writing advanced query

Hi, I am writing a query that can get the journal created 7 days ago. Right now I am doing the following

{
    :title            "⑦ 一星期前"
    :query            [:find (pull ?b [*])
                       :in $ ?span
                       :where
                       (between ?b ?span ?span)
                       ]
    :inputs           [:7d-before ]
   :collapsed?       false}

It works. However it returns all blocks of the journal, sorted by modified time.
I have two questions:

  1. How can I return only the title of the journal instead of individual blocks?
  2. Right now it is sorted by modified time. How can I sort by the original order (as what we will see if we click the journal page)?

Thank you!

1 Like

between only queries blocks not pages. So you can use this below query for that purpose.

#+BEGIN_QUERY
{:title "⑦ 一星期前"
 :query [:find (pull ?p [*])
         :in $ ?d
         :where
         [?p :block/name]
         [?p :block/journal? true]
         [?p :block/journal-day ?d]]
 :inputs [:7d-before]
}
#+END_QUERY
1 Like

Thanks! Nice and clean.

1 Like