PhoenixKitKnowledgeBase.Schemas.Note (PhoenixKitKnowledgeBase v0.1.0)

Copy Markdown View Source

An index row for one markdown file.

The file is the note. Everything here is derived from its path and its bytes, and could be rebuilt by re-reading the vault directory — which is exactly what a rescan does. Nothing in this table is authoritative.

Derived from the path

  • :relative_path — the note's identity, unique per vault because the filesystem makes it so
  • :title — the filename without .md, as in Obsidian
  • :title_key — normalised title, what [[wiki-links]] match on. Not unique: two folders may each hold an Ideas.md, and the index has to describe the disk rather than reject it
  • :folder_path — the directory part, "" at the vault root

Derived from the bytes

  • :content — a cache, so search and rendering never touch the disk
  • :frontmatter — parsed YAML properties, kept whole
  • :tags — front matter tags: merged with inline #tags
  • :content_hash, :file_mtime, :file_size — change detection, the stale-write guard, and rename detection across an external mv

search_vector

The table also carries a generated tsvector column, deliberately not mapped here: Postgres computes it from title and content on every write, so Ecto must never try to write it.

Summary

Functions

Changeset for indexing a file.

The canonical form of a title, used for link resolution.

Types

t()

@type t() :: %PhoenixKitKnowledgeBase.Schemas.Note{
  __meta__: term(),
  content: term(),
  content_hash: term(),
  created_by: term(),
  file_mtime: term(),
  file_size: term(),
  folder_path: term(),
  frontmatter: term(),
  inserted_at: term(),
  relative_path: term(),
  tags: term(),
  title: term(),
  title_key: term(),
  updated_at: term(),
  updated_by: term(),
  uuid: term(),
  vault: term(),
  vault_uuid: term()
}

Functions

changeset(note, attrs)

Changeset for indexing a file.

Callers pass the path and the bytes read from disk; every other field is computed here, so there is no way to persist a row that disagrees with the file it describes.

normalize_title(title)

@spec normalize_title(String.t() | nil) :: String.t() | nil

The canonical form of a title, used for link resolution.

Delegates to PhoenixKitKnowledgeBase.Markdown.normalize_title/1 so indexing and [[wiki-link]] resolution can never normalise differently.