Skip to content

VaultMD / QueryApi

Type Alias: QueryApi

QueryApi = object

Defined in: src/query/models/query-api.ts:15

The read-only query surface over the derived SQLite index, exposed as vault.query. Results are always filtered to notes the vault instance is allowed to read.

Methods

backlinks(path, opts?): Backlink[]

Defined in: src/query/models/query-api.ts:61

Notes that link to path via [[wikilink]] or relative-link resolution. Defaults to limit 100; hard cap 1000.

Parameters

path

string

opts?
limit?

number

offset?

number

Returns

Backlink[]


countNotes()

countNotes(opts?): number

Defined in: src/query/models/query-api.ts:33

Total number of readable notes matching the same NoteFilterqueryNotes accepts — the page-count companion to it. Not capped by limit, so Math.ceil(countNotes(f) / pageSize) is exact.

Parameters

opts?

NoteFilter

Returns

number


countSearch()

countSearch(q, opts?): number

Defined in: src/query/models/query-api.ts:143

Total number of readable notes matching the same query and NoteFilter searchText accepts — the page-count companion to it. Not capped by limit.

Parameters

q

string

opts?

NoteFilter

Returns

number


danglingLinks(opts?): DanglingLink[]

Defined in: src/query/models/query-api.ts:87

Every link in the vault that resolves to no note — the vault-wide sweep for broken [[wikilinks]] and dead relative links, ordered by source path then target. Use it after a rename: NotesApi.moveNote moves a note byte-for-byte and never rewrites inbound links, so this is how the fallout is found. Links naming an attachment file type ([[diagram.png]]) are NOT reported: they can never resolve to a .md note, so they are not breakage — which is why this can return [] for a link outboundLinks shows as resolved: null. Defaults to limit 100; hard cap 1000.

Parameters

opts?
limit?

number

offset?

number

Returns

DanglingLink[]


orphanNotes()

orphanNotes(opts?): NoteHit[]

Defined in: src/query/models/query-api.ts:49

Notes with no place in the link graph, narrowed by the same NoteFilter, ordering and pagination queryNotes accepts.

mode: 'disconnected' (the default) returns notes with no links in either direction — Obsidian's graph "Orphans" filter. mode: 'unreferenced' returns notes nothing links TO, whatever they link out to, so it is the wider set: every disconnected note is also unreferenced.

A link naming an attachment (![[diagram.png]]) is not a graph edge, so a note carrying only those is still an orphan. A link that resolves to nothing still counts as an outgoing edge, so a note carrying only broken links is 'unreferenced' but not 'disconnected'. Links from notes outside the read scope are invisible and never rescue a note.

Parameters

opts?

NoteFilter & object

Returns

NoteHit[]


outboundLinks(path, opts?): OutboundLink[]

Defined in: src/query/models/query-api.ts:73

Links out of path, each with its resolved target (or null if the link dangles). Reports raw resolution, so a link to an attachment ([[diagram.png]]) comes back resolved: null — nothing outside .md is indexed. danglingLinks filters those out, so treat resolved: null as "not a note in this vault", not as "broken". Defaults to limit 100; hard cap 1000.

Parameters

path

string

opts?
limit?

number

offset?

number

Returns

OutboundLink[]


outboundMentions()

outboundMentions(path, opts?): SearchHit[]

Defined in: src/query/models/query-api.ts:123

Notes named in THIS note's body without being linked from it — Obsidian's "Unlinked mentions" in the Outgoing links pane, and the prose counterpart of outboundLinks. A hit is another note whose filename, explicit frontmatter title or alias appears in this note's body at a word boundary and case-insensitively, and which this note does not already link. Ordered by where the mention falls in the body, so hits arrive in reading order.

The snippet quotes the queried note around the name — the hit is the note being named, the surrounding text is this one's.

Carries the same unsegmented-text limitation as unlinkedMentions: a name embedded in Chinese or Japanese prose has no word boundary to match. Defaults to limit 100; hard cap 1000.

Parameters

path

string

opts?
limit?

number

offset?

number

Returns

SearchHit[]


queryNotes()

queryNotes(opts?): NoteHit[]

Defined in: src/query/models/query-api.ts:21

Filter notes by tag, frontmatter field and/or folder — see NoteFilter — with ordering and pagination. Defaults to newest-first (mtime_ms desc), limit 100; hard cap 1000.

Parameters

opts?

NoteFilter & object

Returns

NoteHit[]


searchText()

searchText(q, opts?): SearchHit[]

Defined in: src/query/models/query-api.ts:134

FTS5 keyword search over note bodies, returning highlighted snippets, narrowed by the same NoteFilter the note readers take. Best match first, each hit carrying a higher-is-better score — read SearchHit.score before thresholding on it. Defaults to limit 100; hard cap 1000.

Parameters

q

string

opts?

NoteFilter & object

Returns

SearchHit[]


tags()

tags(opts?): TagInfo[]

Defined in: src/query/models/query-api.ts:151

Every tag present on notes the instance can read, each with the number of those notes that carry it, ranked most-used first (canonical tags float to the top). prefix matches case-sensitively for hierarchy navigation; contains is a substring search (ASCII case-insensitive, per SQLite LIKE); folder restricts to a folder subtree; limit caps the result.

Parameters

opts?
contains?

string

folder?

string

limit?

number

prefix?

string

Returns

TagInfo[]


unlinkedMentions()

unlinkedMentions(path, opts?): SearchHit[]

Defined in: src/query/models/query-api.ts:103

Notes that name this one in prose without linking it — Obsidian's "Unlinked mentions" in the Backlinks pane, and the prose counterpart of backlinks. A hit is a note whose body contains this note's filename, its explicit frontmatter title, or one of its aliases, at a word boundary and case-insensitively, while linking nothing to it. Notes that already link are reported by backlinks instead, never here.

The snippet quotes the mentioning note (the hit) around the name.

Matching needs a word boundary, so a name embedded in unsegmented text — Chinese and Japanese prose, which is written without spaces — is NOT found; only occurrences delimited by spaces or punctuation are. Defaults to limit 100; hard cap 1000.

Parameters

path

string

opts?
limit?

number

offset?

number

Returns

SearchHit[]