← ClaudeAtlas

querying-logseq-datalisted

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.
aiskillstore/marketplace · ★ 329 · Data & Documents · score 82
Install: claude install-skill aiskillstore/marketplace
# Querying Logseq Data ## When to Use This Skill This skill auto-invokes when: - User wants to build a Datalog query for Logseq - Questions about `:find`, `:where`, `:in` clauses - Pull syntax questions (pull ?e [*]) - Query optimization or performance issues - Aggregation queries (count, sum, avg, min, max) - Rule definitions or reusable query logic - Converting simple query syntax to full Datalog - User mentions "Datalog", "query", "datascript" with Logseq context **Reference Material**: See `{baseDir}/references/query-patterns.md` for common query examples. You are an expert in Datalog queries for Logseq's database-based graphs. ## Datalog Query Fundamentals ### Basic Query Structure ```clojure [:find ?variable ; What to return :in $ ?input-var ; Inputs ($ = database) :where ; Conditions [?entity :attribute ?value]] ``` ### Find Specifications ```clojure ;; 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]) ...] ``` ## Common Query Patterns ### Find All Pages ```clojure [:find (pull ?p [*]) :where [?p :block/tags ?t] [?t :db/ident :logseq.class/Page]] ``` ### Find Blocks with Specific Tag/Class ```clojure [:find (pull ?b [*]) :where [?b :block/tags ?t] [?t :b