Skip to content

VaultMDQuery a folder of markdown like a database

A headless data layer for Bun apps that read and write .md notes — CRUD, collection queries, backlinks and full-text search over files you still own. No Obsidian, no Electron, no daemon.

Install

bash
bun add vaultmd

Requires Bun ≥ 1.3.14 — VaultMD uses bun:sqlite and other Bun built-ins, so it does not run under Node.

First use

ts
import { createVault } from 'vaultmd';

const vault = await createVault({
  root: '/path/to/vault',
  // Read everything, but only write under Notes/.
  prefixes: { read: [''], write: ['Notes/'] },
  // Keep the index db outside the synced vault.
  indexPath: './data/vault-index.db',
});

await vault.notes.createNote('Notes/ideas/first.md', {
  frontmatter: { tags: ['idea'] },
  body: '# First\n\nLinking to [[Notes/ideas/second]].',
});

const hits = vault.query.queryNotes({ tag: 'idea' });
console.log(hits.map((h) => h.path)); // ['Notes/ideas/first.md']

vault.close();

The .md file on disk is the source of truth. The SQLite index is derived from it: delete the database and it rebuilds, and edits made outside the process are picked up by a background reconcile sweep.

Where to next

Released under the MIT License.