Help us improve
Share bugs, ideas, or general feedback.
From logseq-expert
Expert in building Datalog queries for Logseq DB graphs. Auto-invokes when users need help writing Logseq queries, understanding Datalog syntax, optimizing query performance, or working with the Datascript query engine. Covers advanced query patterns, pull syntax, aggregations, and DB-specific query techniques.
npx claudepluginhub c0ntr0lledcha0s/claude-code-plugin-automations --plugin logseq-expertHow this skill is triggered — by the user, by Claude, or both
Slash command
/logseq-expert:querying-logseq-dataThis skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
This skill auto-invokes when:
Create and edit Obsidian Bases (.base YAML files) with views, filters, formulas, properties, and summaries for dynamic note organization in Obsidian vaults.
Create and edit Obsidian Bases (.base YAML files) with table, cards, list, map views, filters, formulas, properties, and summaries for dynamic note views.
Creates and edits Obsidian .base files with views (table/cards/list/map), filters (tags, folder, property, date), formulas, and summaries for database-like views of notes.
Share bugs, ideas, or general feedback.
This skill auto-invokes when:
:find, :where, :in clausesReference Material: See {baseDir}/references/query-patterns.md for common query examples.
You are an expert in Datalog queries for Logseq's database-based graphs.
[:find ?variable ; What to return
:in $ ?input-var ; Inputs ($ = database)
:where ; Conditions
[?entity :attribute ?value]]
;; Return all matches as tuples
[:find ?title ?author ...]
;; Return as collection (single variable)
[:find [?title ...] ...]
;; Return single value
[:find ?title . ...]
;; Return single tuple
[:find [?title ?author] ...]
;; Pull entity data
[:find (pull ?e [*]) ...]
[:find (pull ?e [:block/title :block/tags]) ...]
[:find (pull ?p [*])
:where
[?p :block/tags ?t]
[?t :db/ident :logseq.class/Page]]
[:find (pull ?b [*])
:where
[?b :block/tags ?t]
[?t :block/title "Book"]]
;; Exact match
[:find (pull ?b [*])
:where
[?b :user.property/author "Stephen King"]]
;; With variable binding
[:find ?title ?author
:where
[?b :block/title ?title]
[?b :user.property/author ?author]
[?b :block/tags ?t]
[?t :block/title "Book"]]
[:find (pull ?t [*])
:where
[?t :block/tags ?tag]
[?tag :db/ident :logseq.class/Task]
[?t :logseq.property/status ?s]
[?s :block/title "In Progress"]]
;; Tasks due this week
[:find (pull ?t [*])
:in $ ?start ?end
:where
[?t :block/tags ?tag]
[?tag :db/ident :logseq.class/Task]
[?t :logseq.property/deadline ?d]
[(>= ?d ?start)]
[(<= ?d ?end)]]
;; Count books by author
[:find ?author (count ?b)
:where
[?b :block/tags ?t]
[?t :block/title "Book"]
[?b :user.property/author ?author]]
;; Sum, min, max, avg
[:find (sum ?rating) (avg ?rating) (min ?rating) (max ?rating)
:where
[?b :block/tags ?t]
[?t :block/title "Book"]
[?b :user.property/rating ?rating]]
;; Define rules
[[(has-tag ?b ?tag-name)
[?b :block/tags ?t]
[?t :block/title ?tag-name]]
[(is-task ?b)
[?b :block/tags ?t]
[?t :db/ident :logseq.class/Task]]]
;; Use rules in query
[:find (pull ?b [*])
:in $ %
:where
(has-tag ?b "Important")
(is-task ?b)]
;; Find books without rating
[:find (pull ?b [*])
:where
[?b :block/tags ?t]
[?t :block/title "Book"]
(not [?b :user.property/rating _])]
;; Find high priority or overdue tasks
[:find (pull ?t [*])
:in $ ?today
:where
[?t :block/tags ?tag]
[?tag :db/ident :logseq.class/Task]
(or
[?t :logseq.property/priority "High"]
(and
[?t :logseq.property/deadline ?d]
[(< ?d ?today)]))]
;; Find all descendants of a block
[[(descendant ?parent ?child)
[?child :block/parent ?parent]]
[(descendant ?parent ?child)
[?child :block/parent ?p]
(descendant ?parent ?p)]]
[:find (pull ?c [*])
:in $ % ?root-id
:where
[?root :block/uuid ?root-id]
(descendant ?root ?c)]
;; Specific attributes
(pull ?e [:block/title :block/tags])
;; Nested pulling for refs
(pull ?e [:block/title {:block/tags [:block/title]}])
;; All attributes
(pull ?e [*])
;; Limit nested results
(pull ?e [:block/title {:block/children [:block/title] :limit 5}])
;; Find all blocks referencing this entity
(pull ?e [:block/title {:block/_refs [:block/title]}])
;; Find all classes (tags that are themselves tagged as Tag)
[:find (pull ?c [*])
:where
[?c :block/tags ?t]
[?t :db/ident :logseq.class/Tag]]
;; Find class hierarchy
[:find ?parent-name ?child-name
:where
[?child :logseq.property.class/extends ?parent]
[?child :block/title ?child-name]
[?parent :block/title ?parent-name]]
;; Find all user-defined properties
[:find (pull ?p [*])
:where
[?p :block/tags ?t]
[?t :db/ident :logseq.class/Property]
[?p :db/ident ?ident]
[(clojure.string/starts-with? (str ?ident) ":user.property")]]
;; Find property values with type
[:find ?prop-name ?type
:where
[?p :block/tags ?t]
[?t :db/ident :logseq.class/Property]
[?p :block/title ?prop-name]
[?p :logseq.property/type ?type]]
;; Find all journal pages
[:find (pull ?j [*])
:where
[?j :block/tags ?t]
[?t :db/ident :logseq.class/Journal]]
;; Find journal for specific date
[:find (pull ?j [*])
:in $ ?date-str
:where
[?j :block/tags ?t]
[?t :db/ident :logseq.class/Journal]
[?j :block/title ?date-str]]
:db/ident, :block/uuid are indexed;; Optimized query example
[:find (pull ?b [:block/title :user.property/rating])
:in $ ?min-rating
:where
;; Most selective first
[?b :user.property/rating ?r]
[(>= ?r ?min-rating)]
;; Then filter by tag
[?b :block/tags ?t]
[?t :block/title "Book"]]
{{query (and [[Book]] (property :rating 5))}}
[:find (pull ?b [*])
:where
[?b :block/tags ?t]
[?t :block/title "Book"]
[?b :user.property/rating 5]]
#+BEGIN_QUERY
{:title "5-Star Books"
:query [:find (pull ?b [*])
:where
[?b :block/tags ?t]
[?t :block/title "Book"]
[?b :user.property/rating 5]]
:result-transform (fn [result] (sort-by :block/title result))
:view (fn [rows] [:ul (for [r rows] [:li (:block/title r)])])}
#+END_QUERY
MD vs DB attribute differences
:block/content, :block/name:block/title, :block/tagsProperty namespacing
:user.property/name:logseq.property/nameTag vs Class terminology
:logseq.class/*)Date handling