检索journal中所有的一级标题下的block,query高级查询语句怎么写呢?

检索journal中所有的一级标题下的block,query高级查询语句怎么写呢?

网上搜索的都不能使用?请大佬帮忙修改一下:

{:query [:find (pull ?b [*])
         :where
         [?p :block/journal? true]
         [?p :block/children ?b]
         [?b :block/heading 1]]}

这个查询语句的意思是:找到所有具有:block/journal? true属性的页面(即日志页面),然后找到这些页面下的所有子block(即一级标题),然后从这些子block中提取所有具有:block/heading 1属性的block(即一级标题下的block)。最后,用pull ?b [*]来显示这些block的所有属性和内容。

試試看是不是你要的?

#+BEGIN_QUERY
{:query [:find (pull ?b[*])
                :where
                [?p :block/name journal]
                [?b :block/properties {:heading 1}]
                [?b :block/page ?p]
]
}
#+END_QUERY

{{query (and (between -1w today) (property heading 1))}}更新0.9.6可用

#+BEGIN_QUERY
{:query [:find (pull ?b[*])
                :where
                ;↓日志中检索
                [?p :block/journal? true]
                [?b :block/page ?p]
                ;↓如果一级标题,则检测出,成功(!但是,如果一级标题有block属性,检测不出😭)
                [?b :block/properties {:heading 1}]
]
}
#+END_QUERY

這應該可以找到有block屬性

#+BEGIN_QUERY
{:query [:find (pull ?b[*])
       :where
       [?p :block/journal? true]
       [?b :block/page ?p]
       [?b :block/properties ?pr]
       [(get ?pr :heading) ?pp]
       [(== ?pp 1)]
]
}
#+END_QUERY
1 个赞

成功!!但以后的列表估计会很长。
加了一个时间期限,没成功,求指教。

#+BEGIN_QUERY
{:title [:b "我的黑曜石 "]
 :query [:find (pull ?b[*])
       :in $ ?one-month-ago ?today
       :where
       [?p ::block/journal-day ?d]
      ;; 限定日期范围
        [(>= ?d ?one-month-ago)] 
        [(<= ?d ?today)]
       [?b :block/page ?p]
       [?b :block/properties ?pr]
       [(get ?pr :heading) ?pp]
       [(== ?pp 1)]
 :inputs [:-30d :today]
]
}
#+END_QUERY
#+BEGIN_QUERY
{:query [:find (pull ?b[*])
       :in $ ?start ?end
       :where
       [?p :block/journal-day ?d]
        [(>= ?d ?start)] 
        [(<= ?d ?end)]
       [?p :block/journal? true]
       [?b :block/page ?p]
       [?b :block/properties ?pr]
       [(get ?pr :heading) ?pp]
       [(== ?pp 1)]
]
:inputs [:-30d :today]
}
#+END_QUERY
2 个赞

:pray: :pray:感谢~~~~~~~~~~~~~