Skip to main content

turbovault_sql/
lib.rs

1//! # turbovault-sql
2//!
3//! SQL query engine for Obsidian vault frontmatter powered by GlueSQL.
4//!
5//! Builds in-memory tables from vault data and lets MCP clients execute
6//! arbitrary SQL queries. Three tables are auto-populated:
7//!
8//! - **`files`** — One row per markdown file with `path` + all frontmatter keys
9//! - **`tags`** — Unnested `(path, tag)` pairs from frontmatter tag arrays
10//! - **`links`** — `(source, target, link_type, is_valid)` from the vault link graph
11//!
12//! ## Example queries
13//!
14//! ```sql
15//! -- Find all active tasks
16//! SELECT path, status, priority FROM files
17//! WHERE type = 'task' AND status = 'active'
18//! ORDER BY priority DESC;
19//!
20//! -- Tag frequency report
21//! SELECT tag, COUNT(*) AS cnt FROM tags
22//! GROUP BY tag ORDER BY cnt DESC LIMIT 10;
23//!
24//! -- Notes tagged 'work' with broken outgoing links
25//! SELECT DISTINCT t.path FROM tags t
26//! JOIN links l ON t.path = l.source
27//! WHERE t.tag = 'work' AND l.is_valid = FALSE;
28//! ```
29
30mod convert;
31mod engine;
32
33pub use engine::{FrontmatterSqlEngine, SqlSession};