?
ReaderConfig
TypeThe handlers defineReader takes: read and removed, plus optional cleared and relinked.
read(document) runs when a document's first build lands on the source's active version. It never runs for index maintenance (a rebuild, a relink, a re-vectorize) or for an in-place metadata change, because the reader is about what the text says. removed(documentId) runs when the document is gone and receives only its id. cleared(sourceId) runs once when the whole source is deleted, so the app can drop that source's rows in one statement. relinked(document) runs when a new dictionary re-tags a document already read. The text is unchanged, so use it for rows derived from the tags, not to extract again. Without it, a relink delivers nothing.
ReaderConfig.ts
interface ReaderConfig { read: (document: ReaderDocument) => MaybePromise<void> removed: (documentId: string) => MaybePromise<void> cleared?: (sourceId: string) => MaybePromise<void> relinked?: (document: ReaderDocument) => MaybePromise<void> }
Fields
read
(document: ReaderDocument) => void
A document's first build landed. Replace that document's rows as a set.
removed
(documentId: string) => void
The document is gone. Delete its rows.
cleared?
(sourceId: string) => void
The whole source was deleted. Called once.
relinked?
(document: ReaderDocument) => void
A new dictionary re-tagged a document already read. Without it a relink delivers nothing.
Follow re-tagging
defineReader(Manuals, {
read, removed,
relinked: async (document) => {
await syncAssetLinks(document.id, await document.chunks()); // rows derived from tags only
},
});