Skip to content

feat(update): add -c/--collection filter to qmd update#566

Open
erlebach wants to merge 2 commits intotobi:mainfrom
erlebach:feat/update-collection-filter
Open

feat(update): add -c/--collection filter to qmd update#566
erlebach wants to merge 2 commits intotobi:mainfrom
erlebach:feat/update-collection-filter

Conversation

@erlebach
Copy link
Copy Markdown

@erlebach erlebach commented Apr 13, 2026

fix(update): add -c/--collection filter to qmd update

Summary

  • qmd update now accepts -c <name> (or --collection <name>) to re-index a single collection instead of all collections
  • Multiple -c flags are supported (e.g. qmd update -c notes -c work)
  • The completion message now names the collection when only one was updated (e.g. ✓ 'notes' updated. vs ✓ 3 collections updated.)
  • Fix: added transaction to the Database interface in src/db.ts, which was used in store.ts but missing from the type definition (caused a build failure under updated better-sqlite3 type declarations)

Behaviour

qmd update                    # unchanged — updates all collections
qmd update -c mynotes         # updates only the 'mynotes' collection
qmd update -c notes -c work   # updates two specific collections
qmd update -c nonexistent     # exits with error: "Collection 'nonexistent' not found."

Files changed

  • src/cli/qmd.tsupdateCollections() accepts optional collectionFilter?: string[]; filters and validates before iterating; updated completion message
  • src/db.ts — added transaction<T> to the Database interface

  1. Completion message — instead of always printing ✓ All collections updated., it now prints the collection name when exactly one was
  updated (e.g. ✓ 'mynotes' updated.), and falls back to ✓ N collections updated. for multiple.
  2. Type normalization — cli.opts.collection is typed as string | string[] | undefined (because multiple: true in parseArgs doesn't guarantee
   an array when called with a single value). The ternary normalizes it to string[] | undefined before passing to updateCollections.
  3. Database interface fix — transaction was called on a Database instance in store.ts but was absent from the interface definition, causing
  a TypeScript build error. Added the correct generic signature transaction<T>(fn: () => T): () => T.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant