logseq-schema
Original:🇺🇸 English
Translated
Logseq Datascript schema, built-in properties/classes, and :db/ident discovery for composing or reviewing Datascript queries about blocks/pages/tags/properties/classes. Use whenever editing or reviewing Datascript pull selectors or queries, or any code that adds/removes attributes in pull patterns, or touches property namespaces/identifiers, or requires reasoning about property value shapes/ref/cardinality in Logseq.
7installs
Sourcercmerci/skills
Added on
NPX Install
npx skill4agent add rcmerci/skills logseq-schemaTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →Logseq Schema
Overview
Use this skill to ground Datascript queries in Logseq's schema: core block/page/file attributes, built-in properties, built-in classes, and schema entities with :db/ident. Load for authoritative sources and query patterns, and
for scenario-based query examples.
references/logseq-datascript-schema.mdreferences/logseq-datascript-query-examples.mdGlossary
- : Internal numeric entity id (use with CLI flags like
db/id).--id - : Stable UUID for a block entity; prefer when you need a persistent reference.
:block/uuid - : Lowercased page name, used for page lookup and joins.
:block/name - : Block or page title stored in the DB graph (use in queries when content text is needed).
:block/title - : Ref-many attribute linking blocks to tag/page entities.
:block/tags - : Namespace for user-defined properties stored directly on block entities.
:user.property/<name> - : Namespace for built-in properties stored directly on block entities.
:logseq.property/*
Important Notes
- Never use following block attrs in or
query, these attrs are file-graph only, never used in db-graphs:pull,:block/format,:block/level,:block/level-spaces,:block/pre-block?,:block/properties-order,:block/properties-text-values,:block/invalid-properties,:block/macros,:block/file,:block.temp/ast-body,:block.temp/ast-blocks,:block/marker,:block/content,:block/priority,:block/scheduled,:block/deadline,:block/properties.:block/left - User properties are stored as attributes on the block/page entity.
:user.property/<name> - Pull selectors do NOT support namespace wildcards like or
:user.property/*. Only:logseq.property/*(all attributes) or explicit attributes are allowed in*.pull - To fetch user properties, either:
- Query datoms and filter attributes by namespace (e.g., ), then merge into the entity map, or
user.property - Discover explicit user property idents (via ) and include them explicitly in the pull selector.
:db/ident
- Query datoms and filter attributes by namespace (e.g.,
- Property values are often entities/refs (not always scalars). When rendering values, check for ,
:block/title, or:block/nameon the value entity before falling back to stringifying.:logseq.property/value - Many properties are (values may be sets/vectors). Treat them as collections in queries and formatting.
:db.cardinality/many
Datascript Query Mistakes To Avoid
- In
query/:where/pull, attributes cannot use namespace wildcards (e.g.,find,:logseq.property/*); you must use full attr:user.property/*values (e.g.,:db/ident,:logseq.property/status). In:user.property/background, onlypull(all attributes) is special.* - Avoid nesting function calls inside predicates in (some Datascript engines reject or mis-handle it). Bind the function result first, then compare.
:where
Example of safe namespace filtering:
clojure
[:find [?a ...]
:where
[?e :db/ident ?a]
[(namespace ?a) ?ns]
[(= ?ns "user.property")]]Workflow
1) Locate schema facts
- Open .
references/logseq-datascript-schema.md - Review the core attribute list and helper sets for ref/cardinality details.
- Review built-in properties and classes to understand available attributes and required fields.
2) Write or validate queries
- Prefer attributes for block/page queries; use properties/classes only when needed.
:block/* - If unsure about available entities, run the CLI query listed in the references file.
:db/ident - For user properties, query against directly; for built-ins, use
:user.property/<name>.:logseq.property/<name>
3) Keep queries consistent with schema
- Respect ref vs scalar attributes and when joining.
:db.cardinality/many - Use property/class definitions to confirm public/queryable status before exposing a query to users.
Resources
references/
logseq-datascript-schema.mdlogseq-datascript-query-examples.md
Quick Examples
Pull user properties for a block
clojure
;; Discover idents, then pull explicitly.
[:db/id :block/title :user.property/background :user.property/notes]Query blocks with a user property
clojure
[:find ?b ?v
:where
[?b :user.property/background ?v]]Render a property value
Order of preference when value is a map/entity:
:block/title:block/name:logseq.property/value