pub struct UpdateBuilder { /* private fields */ }Expand description
Build an update mutation. The filter selects records; the chained
set/unset/add_tag/remove_tag calls accumulate operations applied
to each matching record’s frontmatter. Body mutations
(set_body/append_body/clear_body) operate on the markdown
section after the frontmatter.
Implementations§
Source§impl UpdateBuilder
impl UpdateBuilder
pub fn new(folder: impl Into<String>, filter: Expr) -> Self
Sourcepub fn recursive(self, yes: bool) -> Self
pub fn recursive(self, yes: bool) -> Self
Recurse into subfolders when selecting records to update (default
false — only files directly in folder are considered). Mirrors
the query recursion flag, so a --where mutation can span a
subtree of scattered records (e.g. index notes) in one call.
pub fn set(self, field: impl Into<String>, value: Value) -> Self
pub fn unset(self, field: impl Into<String>) -> Self
pub fn add_tag(self, tag: impl Into<String>) -> Self
pub fn remove_tag(self, tag: impl Into<String>) -> Self
Sourcepub fn set_body(self, text: impl Into<String>) -> Self
pub fn set_body(self, text: impl Into<String>) -> Self
Replace the body (everything after the closing --- of the
frontmatter) with text. Written verbatim — include a trailing
newline in text if you want one on disk.
Sourcepub fn append_body(self, text: impl Into<String>) -> Self
pub fn append_body(self, text: impl Into<String>) -> Self
Append text to the existing body, joined by the configured
separator (default "\n"). Multiple calls accumulate; each
appended chunk is joined to the running body via the same
separator. Empty bodies receive text as-is (no leading
separator).
Sourcepub fn clear_body(self) -> Self
pub fn clear_body(self) -> Self
Clear the body entirely. Applied before set_body / append_body
in the same builder, so a chain like
.clear_body().append_body("…") is equivalent to .set_body("…").
Sourcepub fn body_separator(self, sep: impl Into<String>) -> Self
pub fn body_separator(self, sep: impl Into<String>) -> Self
Override the separator used between the existing body and each
appended chunk. Default "\n" (compact join — one newline
between old and new content, even if the existing body had a
trailing newline). Pass "\n\n" for a blank-line / section-break
separator.
Sourcepub fn with_vault_schema(self, schema: VaultSchema) -> Self
pub fn with_vault_schema(self, schema: VaultSchema) -> Self
Attach the vault-wide schema. When set, every matched record’s
post-update field map is validated against all applicable
collections (folder ancestor + filter match) before the writer
runs. A record whose projected state would violate any
applicable collection is reported as a MutationError and
skipped — the rest of the batch still proceeds. Strict mode:
the whole projected record must validate, so pre-existing
violations surface on the first update touching the record.
Sourcepub fn write_options(self, opts: WriteOptions) -> Self
pub fn write_options(self, opts: WriteOptions) -> Self
Replace the writer::WriteOptions used by execute. See its
docs for what each field controls. Defaults to fast (no fsync).
Sourcepub fn fsync(self, yes: bool) -> Self
pub fn fsync(self, yes: bool) -> Self
Convenience: enable durable writes (fsync data + parent dir).
Equivalent to .write_options(WriteOptions::durable()).
Sourcepub fn plan(&self, vault: &Vault) -> Result<MutationReport>
pub fn plan(&self, vault: &Vault) -> Result<MutationReport>
Compute the report without writing.
Sourcepub fn execute(self, vault: &Vault) -> Result<MutationReport>
pub fn execute(self, vault: &Vault) -> Result<MutationReport>
Plan, then apply each computed WriteResult to disk.
Holds the vault-scoped exclusive lock (see crate::lock) for the
entire duration of compute + writes, so concurrent mutations from
other vaultdb-core consumers serialize cleanly. Each individual
file write is atomic via tempfile+rename — readers never see a
partial write.
Trait Implementations§
Source§impl Clone for UpdateBuilder
impl Clone for UpdateBuilder
Source§fn clone(&self) -> UpdateBuilder
fn clone(&self) -> UpdateBuilder
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more