Files
logseq/deps/db
scheinriese 749a032d04 feat: persist asset attribution metadata
Adds four asset-scoped properties so Logseq can keep the provenance of an
image alongside the file:

- :logseq.property.asset/source-url — Wikimedia descriptionurl, Wikipedia
  page, or any user-supplied source link. Queryable; this is the join
  key the asset-picker uses to dedup web-image hits against the local
  library.
- :logseq.property.asset/source-name — short label ("Wikimedia Commons",
  "Wikipedia", etc.). Queryable.
- :logseq.property.asset/license — license slug (CC-BY-SA-3.0 etc.).
  Queryable.
- :logseq.property.asset/attribution — full credit string for embed/
  export contexts. Not queryable.

Schema bumped 65.26 → 65.29 with three migrations:

- 65.27: register the four new properties.
- 65.28: an in-development DB hit a build that registered source-url
  with :type :url (a ref-typed schema), which made datascript treat
  plain URL strings as tempid lookups and blocked every asset save with
  "Tempids used only as value in transaction". Coerces the entity's
  :logseq.property/type back to :string.
- 65.29: 65.28 corrected the type but left :db/valueType :db.type/ref on
  the same entity. In Logseq's datascript fork the :db/valueType on a
  :db/ident-keyed entity IS the live schema, so the attribute stayed
  ref-typed and string URLs continued to fail. Retracts :db/valueType
  to release the lock; mirrors logseq.outliner.property's existing
  ref→non-ref pattern.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-07 13:38:54 +02:00
..
2026-03-13 13:20:49 +08:00
2025-06-10 08:47:52 -04:00
2026-03-13 13:20:49 +08:00

Description

This library provides an API to the frontend(datascript) and backend(SQLite) databases from the Logseq app and the CLI. This library defines the core schema and fns for DB graphs. There are a few namespaces that also support file graphs for the graph-parser. This library is compatible with ClojureScript and with nbb-logseq to respectively provide frontend and commandline functionality.

API

This library is under the parent namespace logseq.db. It provides the following namespaces:

  • logseq.db - main public ns. Most often used by frontend
  • logseq.db.frontend.* - frontend namespaces for DB graphs
  • logseq.db.sqlite.* - backend/sqlite namespaces for DB graphs
  • logseq.db.common.* - frontend and backend namespaces for DB graphs

The following namespaces are used with file graphs via the graph-parser: logseq.db.common.order, logseq.db.frontend.entity-util and logseq.db.common.entity-plus.

Usage

See the frontend for example usage.

Dev

This follows the practices that the Logseq frontend follows. Most of the same linters are used, with configurations that are specific to this library. See this library's CI file for linting examples.

Setup

To run linters and tests, you'll want to install yarn dependencies once:

yarn install

This step is not needed if you're just running the application.

Testing

Testing is done with nbb-logseq and nbb-test-runner. Some basic usage:

# Run all tests
$ yarn test
# List available options
$ yarn test -H
# Run tests with :focus metadata flag
$ yarn test -i focus

Datalog linting

Datalog rules for the client are linted through a script that also uses the datalog-parser. To run this linter:

bb lint:rules

Managing dependencies

The package.json dependencies are just for testing and should be updated if there is new behavior to test.

The deps.edn dependencies are used by both ClojureScript and nbb-logseq. Their versions should be backwards compatible with each other with priority given to the frontend. No new dependency should be introduced to this library without an understanding of the tradeoffs of adding this to nbb-logseq.