Dataview is a live index and query engine over your personal knowledge base. You can add metadata to your notes and query them with the Dataview Query Language to list, filter, sort or group your data. Dataview keeps your queries always up to date and makes data aggregation a breeze.
β Obsidian Dataview β
Dataview is a plugin for Obsidian β . However, we can build our own βDataviewβ with BrainDB :
Use remark-code-hook β to catch all code blocks with the dataview
language
Treat the code as SQL and execute wiht BrainDB
Translate the result to MDAST (or HTML)
Installation
Install BrainDB
Install dependencies
pnpm add @braindb/remark-dataview
Configure Astro. See note about Rehype Plugins for Code .
import remarkDataview from " @braindb/remark-dataview " ;
import { getBrainDb } from " @braindb/astro " ;
const bdb = getBrainDb ();
export default defineConfig ({
remarkPlugins: [[ remarkDataview , { bdb }]],
Examples
Alphabetical index
Query:
```dataview list root_class=column-list
SELECT upper(substr(frontmatter ->> '$.title', 1, 1)), dv_link()
WHERE (frontmatter ->> '$.draft' IS NULL OR frontmatter ->> '$.draft' = false)
AND frontmatter ->> '$.tags' IS NOT NULL
ORDER BY frontmatter ->> '$.title'
Output:
Recently changed
Query:
```dataview list root_class=column-list
SELECT date(updated_at / 1000, 'unixepoch'), dv_link()
WHERE (frontmatter ->> '$.draft' IS NULL OR frontmatter ->> '$.draft' = false)
AND frontmatter ->> '$.tags' IS NOT NULL
Output:
Task list
Query:
SELECT dv_link(), dv_task()
FROM tasks JOIN documents ON documents.path = tasks.from
WHERE (frontmatter ->> '$.draft' IS NULL OR frontmatter ->> '$.draft' = false)
AND frontmatter ->> '$.tags' IS NOT NULL
ORDER BY updated_at DESC, path, tasks.start
Output:
Query:
```dataview list root_class=column-list
SELECT '#' || tags.value as tag, dv_link()
FROM documents, json_each(frontmatter, '$.tags') tags
WHERE (frontmatter ->> '$.draft' IS NULL OR frontmatter ->> '$.draft' = false)
AND frontmatter ->> '$.tags' IS NOT NULL
Output: