skills/c0ntr0lledcha0s/querying-logseq-data/SKILL.md
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 skillsauth add aiskillstore/marketplace querying-logseq-dataInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
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
development
Apple Human Interface Guidelines for content display components. Use this skill when the user asks about charts component, collection view, image view, web view, color well, image well, activity view, lockup, data visualization, content display, displaying images, rendering web content, color pickers, or presenting collections of items in Apple apps. Also use when the user says how should I display charts, what's the best way to show images, should I use a web view, how do I build a grid of items, what component shows media, or how do I present a share sheet. Cross-references: hig-foundations for color/typography/accessibility, hig-patterns for data visualization patterns, hig-components-layout for structural containers, hig-platforms for platform-specific component behavior.
tools
Automate HelpDesk tasks via Rube MCP (Composio): list tickets, manage views, use canned responses, and configure custom fields. Always search tools first for current schemas.
testing
Expert Haskell engineer specializing in advanced type systems, pure functional design, and high-reliability software. Use PROACTIVELY for type-level programming, concurrency, and architecture guidance.
tools
GraphQL gives clients exactly the data they need - no more, no less. One endpoint, typed schema, introspection. But the flexibility that makes it powerful also makes it dangerous. Without proper controls, clients can craft queries that bring down your server. This skill covers schema design, resolvers, DataLoader for N+1 prevention, federation for microservices, and client integration with Apollo/urql. Key insight: GraphQL is a contract. The schema is the API documentation. Design it carefully.