Class: TopicalIndexRepository
Defined in: Data/Repositories/TopicalIndexRepository.ts:60
Repository for Topical Index module databases (topical_*.db)
Handles all operations for a topical index database:
- Module information
- Topic hierarchy (parent/child, breadcrumbs)
- Topic-verse associations
- Full-text search via FTS5
v1/v2 compatibility. Topic→verse associations are read from the unified
verse_link table (source_type='topic') when it exists, and from the legacy
topic_verses table otherwise. Table and column names are resolved once per
connection. Every fallback below is a Pass-2 deletion point.
Example
const navesDb = new SqliteProvider('data/modules/topical_nave.db');
const repo = new TopicalIndexRepository(navesDb);
// Get topics for a verse
const topics = repo.getTopicsByVerse(43003016); // John 3:16
// Browse hierarchy
const children = repo.getChildren(topicId);
const breadcrumb = repo.getParentChain(topicId);
// Search
const results = repo.searchTopics('love');
Extends
Implements
Constructors
Constructor
new TopicalIndexRepository(
sql):TopicalIndexRepository
Defined in: Data/Repositories/TopicalIndexRepository.ts:73
Parameters
sql
Returns
TopicalIndexRepository
Overrides
BaseModuleRepository.constructor
Methods
getAllTopicsPaginated()
getAllTopicsPaginated(
options?):Topic[]
Defined in: Data/Repositories/TopicalIndexRepository.ts:221
One page of topics, ordered by name.
rootsOnly restricts the page to top-level topics. It applies to plain
browsing only: a filtered (FTS) page always spans every level, because a
reader who types a subtopic's name is asking for that subtopic. See the
implementation for why the top level is the right default for browsing.
Parameters
options?
filter?
string
limit?
number
offset?
number
rootsOnly?
boolean
Returns
Topic[]
Implementation of
ITopicalIndexRepository.getAllTopicsPaginated
getAllTopicSummaries()
getAllTopicSummaries():
TopicSummary[]
Defined in: Data/Repositories/TopicalIndexRepository.ts:440
Bulk-read all topics as flat summary rows. Used by aggregation services that pre-compute parent chains and recursive counts in JS rather than via per-topic CTE queries.
Result order matches sqlite's natural row order (no ORDER BY) so output is reproducible per-DB without sorting overhead.
Returns
Implementation of
ITopicalIndexRepository.getAllTopicSummaries
getAllTopicVerseLinks()
getAllTopicVerseLinks():
TopicVerseLink[]
Defined in: Data/Repositories/TopicalIndexRepository.ts:464
Bulk-read every topic↔verse link.
Rows where the start equals the end represent a single verse; otherwise the
range is inclusive on both ends. Callers that need a flat per-verse map
should expand by walking [verseIdStart, verseIdEnd] inclusive.
Returns
Implementation of
ITopicalIndexRepository.getAllTopicVerseLinks
getChildCounts()
getChildCounts(
topicIds):ReadonlyMap<number,number>
Defined in: Data/Repositories/TopicalIndexRepository.ts:161
Number of direct children for each of topicIds, in one grouped query.
The browse list needs this for every row it draws, and the top level of
Nave's alone is 5,320 rows — one getChildren call per row would be a
query per row per page. Topics with no children are absent from the map
rather than present with a zero.
Parameters
topicIds
number[]
Returns
ReadonlyMap<number, number>
Implementation of
ITopicalIndexRepository.getChildCounts
getChildren()
getChildren(
parentTopicId):Topic[]
Defined in: Data/Repositories/TopicalIndexRepository.ts:136
Parameters
parentTopicId
number
Returns
Topic[]
Implementation of
ITopicalIndexRepository.getChildren
getModuleInfo()
getModuleInfo():
TopicalIndexModuleInfo|undefined
Defined in: Data/Repositories/BaseModuleRepository.ts:137
Get module metadata from the module_info table. Every module database has exactly one row in module_info (info_id = 1).
Returns
TopicalIndexModuleInfo | undefined
Implementation of
ITopicalIndexRepository.getModuleInfo
Inherited from
BaseModuleRepository.getModuleInfo
getParentChain()
getParentChain(
topicId):Topic[]
Defined in: Data/Repositories/TopicalIndexRepository.ts:177
Get the parent chain from a topic up to the root (breadcrumb). Returns array from root to the topic's direct parent.
Parameters
topicId
number
Returns
Topic[]
Implementation of
ITopicalIndexRepository.getParentChain
getRecursiveReferenceCount()
getRecursiveReferenceCount(
topicId):number
Defined in: Data/Repositories/TopicalIndexRepository.ts:404
getReferenceCount across a topic and all its descendants.
Parameters
topicId
number
Returns
number
Implementation of
ITopicalIndexRepository.getRecursiveReferenceCount
getRecursiveVerseCount()
getRecursiveVerseCount(
topicId):number
Defined in: Data/Repositories/TopicalIndexRepository.ts:484
Parameters
topicId
number
Returns
number
Implementation of
ITopicalIndexRepository.getRecursiveVerseCount
getRecursiveVersesForTopic()
getRecursiveVersesForTopic(
topicId,options?):TopicVerse[]
Defined in: Data/Repositories/TopicalIndexRepository.ts:306
Parameters
topicId
number
options?
limit?
number
offset?
number
Returns
Implementation of
ITopicalIndexRepository.getRecursiveVersesForTopic
getReferenceCount()
getReferenceCount(
topicId):number
Defined in: Data/Repositories/TopicalIndexRepository.ts:386
Number of verse links stored for a topic — the unit getVersesForTopic
paginates in. Unlike getVerseCount this does not expand ranges, so
it is the only count that can safely be compared against a loaded row count
to decide whether more pages exist.
Parameters
topicId
number
Returns
number
Implementation of
ITopicalIndexRepository.getReferenceCount
getRootTopics()
getRootTopics():
Topic[]
Defined in: Data/Repositories/TopicalIndexRepository.ts:144
Returns
Topic[]
Implementation of
ITopicalIndexRepository.getRootTopics
getTopic()
getTopic(
topicId):Topic|undefined
Defined in: Data/Repositories/TopicalIndexRepository.ts:96
Parameters
topicId
number
Returns
Topic | undefined
Implementation of
ITopicalIndexRepository.getTopic
getTopicCount()
getTopicCount(
filter?,options?):number
Defined in: Data/Repositories/TopicalIndexRepository.ts:253
Counts what getAllTopicsPaginated pages through, same options.
Parameters
filter?
string
options?
rootsOnly?
boolean
Returns
number
Implementation of
ITopicalIndexRepository.getTopicCount
getTopicsByName()
getTopicsByName(
name):Topic[]
Defined in: Data/Repositories/TopicalIndexRepository.ts:213
Parameters
name
string
Returns
Topic[]
Implementation of
ITopicalIndexRepository.getTopicsByName
getTopicsByVerse()
getTopicsByVerse(
verseId):Topic[]
Defined in: Data/Repositories/TopicalIndexRepository.ts:104
Parameters
verseId
number
Returns
Topic[]
Implementation of
ITopicalIndexRepository.getTopicsByVerse
getVerseCount()
getVerseCount(
topicId):number
Defined in: Data/Repositories/TopicalIndexRepository.ts:359
Parameters
topicId
number
Returns
number
Implementation of
ITopicalIndexRepository.getVerseCount
getVersesForTopic()
getVersesForTopic(
topicId,options?):TopicVerse[]
Defined in: Data/Repositories/TopicalIndexRepository.ts:277
Parameters
topicId
number
options?
limit?
number
offset?
number
Returns
Implementation of
ITopicalIndexRepository.getVersesForTopic
searchTopics()
searchTopics(
query,options?):Topic[]
Defined in: Data/Repositories/TopicalIndexRepository.ts:195
Parameters
query
string
options?
limit?
number
offset?
number
Returns
Topic[]