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//! - [`LoadResult`], [`ParseError`]: parse-diagnostic surfacing for
40//!   [`Vault::load_records`].
41//! - [`VaultdbError`], [`Result`]: error types.
42//!
43//! ## Design philosophy
44//!
45//! No daemon, no cache, no state files. Every read traverses the filesystem
46//! fresh. Stateful concerns (file watchers, full-text indexes, typed schemas)
47//! belong in consumers, not in vaultdb-core.
48
49pub mod dsl;
50pub mod error;
51pub mod filter;
52pub mod frontmatter;
53pub mod journal;
54pub mod links;
55pub mod lock;
56pub mod mutation;
57pub mod query;
58pub mod record;
59pub mod schema;
60pub mod vault;
61pub mod writer;
62
63pub use error::{ParseError, Result, VaultdbError};
64pub use links::{Direction, GraphScope, LinkGraph, UnresolvedLink};
65pub use mutation::{
66    DeleteBuilder, MoveBuilder, MutationError, MutationReport, PlannedChange, RenameBuilder,
67    UpdateBuilder,
68};
69pub use query::{CompareOp, Expr, LinkPredicate, Predicate, Query, SortKey};
70pub use record::{Record, Value};
71pub use vault::{LoadResult, QueryIter, Vault};
72pub use writer::WriteOptions;