Skip to main content

vaultdb_core/
lib.rs

1//! # vaultdb-core
2//!
3//! A markdown-as-database engine. Treats folders of `.md` files with YAML
4//! frontmatter as queryable structured data, with `[[wikilinks]]` forming a
5//! first-class link graph. Both the tabular (frontmatter) and graph (link)
6//! shapes are equally first-class — you can filter records by frontmatter,
7//! by graph predicates ("links to anything tagged X"), or by any combination.
8//!
9//! ## Quick start
10//!
11//! ```no_run
12//! use vaultdb_core::{Expr, Predicate, Query, Value, Vault};
13//!
14//! let vault = Vault::discover(std::path::Path::new(".")).unwrap();
15//! let q = Query {
16//!     folder: "notes".into(),
17//!     filter: Some(Expr::Predicate(Predicate::Equals {
18//!         field: "status".into(),
19//!         value: Value::String("active".into()),
20//!     })),
21//!     select: None,
22//!     sort: None,
23//!     limit: Some(10),
24//!     recursive: false,
25//! };
26//! let records = vault.query(&q).unwrap();
27//! ```
28//!
29//! ## Public API surface
30//!
31//! - [`Vault`]: entry point. Discover, load, query, build the link graph.
32//! - [`Record`] and [`Value`]: the row + cell types.
33//! - [`Expr`], [`Predicate`], [`LinkPredicate`], [`Query`]: the query AST.
34//! - [`LinkGraph`], [`GraphScope`], [`Direction`], [`UnresolvedLink`]: the link
35//!   graph and its traversal/scoping types.
36//! - [`UpdateBuilder`], [`DeleteBuilder`], [`MoveBuilder`], [`RenameBuilder`]:
37//!   typed mutation API. Each has [`UpdateBuilder::plan`]-style preview and
38//!   `execute` commit methods.
39//! - [`render`]: serialize query results to CSV / JSON / YAML / XLSX and
40//!   write them to a vault-scoped path. The CLI's `--output` flag and the
41//!   MCP read tools' `export` parameter both use this. XLSX is behind
42//!   the `xlsx` Cargo feature.
43//! - [`LoadResult`], [`ParseError`]: parse-diagnostic surfacing for
44//!   [`Vault::load_records`].
45//! - [`VaultdbError`], [`Result`]: error types.
46//!
47//! ## Design philosophy
48//!
49//! No daemon, no cache, no state files. Every read traverses the filesystem
50//! fresh. Stateful concerns (file watchers, full-text indexes, typed schemas)
51//! belong in consumers, not in vaultdb-core.
52
53pub mod dsl;
54pub mod error;
55pub mod filter;
56pub mod frontmatter;
57pub mod journal;
58pub mod links;
59pub mod lock;
60pub mod mutation;
61pub mod query;
62pub mod record;
63pub mod render;
64pub mod schema;
65pub mod vault;
66pub mod writer;
67
68pub use error::{ParseError, Result, VaultdbError};
69pub use links::{Direction, GraphScope, LinkGraph, UnresolvedLink};
70pub use mutation::{
71    CreateBuilder, DeleteBuilder, MoveBuilder, MutationError, MutationReport, PlannedChange,
72    RenameBuilder, UpdateBuilder,
73};
74pub use query::{CompareOp, Expr, LinkPredicate, Predicate, Query, SortKey};
75pub use record::{Record, Value};
76pub use render::{Format as ExportFormat, export_records, export_value, resolve_export_path};
77pub use vault::{LoadResult, QueryIter, Vault};
78pub use writer::WriteOptions;