Class: CrossReferenceRepository
Defined in: Data/Repositories/CrossReferenceRepository.ts:42
Repository for Cross-Reference module databases (xref_*.db)
Handles all operations for a cross-reference database:
- Module information
- Phrase-grouped and verse-level cross-references
- Reverse lookups ("where is this verse referenced?")
Example
const tskDb = new SqliteProvider('data/modules/xref_tsk.db');
const repo = new CrossReferenceRepository(tskDb);
// Get phrase-grouped cross-refs for a verse
const groups = repo.getGroupsWithEntries(43003016); // John 3:16
for (const { group, entries } of groups) {
console.log(group.phrase ?? '(General)');
entries.forEach(e => console.log(` -> ${e.targetVerseId}`));
}
// Reverse lookup
const refs = repo.getReverseReferences(45005008); // Rom 5:8
Extends
Implements
Constructors
Constructor
new CrossReferenceRepository(
sql):CrossReferenceRepository
Defined in: Data/Repositories/CrossReferenceRepository.ts:45
Parameters
sql
Returns
CrossReferenceRepository
Overrides
BaseModuleRepository.constructor
Methods
getEntriesForGroup()
getEntriesForGroup(
groupId):ModuleCrossRefEntry[]
Defined in: Data/Repositories/CrossReferenceRepository.ts:188
Target passages of a phrase group.
v2 reads the unified verse_link table; v1 COMPAT falls back to the
cross_reference_entry table. Either way the caller receives
ModuleCrossRefEntry. Pass-2 deletion point for the fallback.
Parameters
groupId
number
Returns
Implementation of
ICrossReferenceRepository.getEntriesForGroup
getEntryCount()
getEntryCount(
verseId):number
Defined in: Data/Repositories/CrossReferenceRepository.ts:377
Parameters
verseId
number
Returns
number
Implementation of
ICrossReferenceRepository.getEntryCount
getGroupsForVerse()
getGroupsForVerse(
verseId):CrossReferenceGroup[]
Defined in: Data/Repositories/CrossReferenceRepository.ts:168
Parameters
verseId
number
Returns
Implementation of
ICrossReferenceRepository.getGroupsForVerse
getGroupsWithEntries()
getGroupsWithEntries(
verseId):CrossReferenceGroupWithEntries[]
Defined in: Data/Repositories/CrossReferenceRepository.ts:204
Parameters
verseId
number
Returns
CrossReferenceGroupWithEntries[]
Implementation of
ICrossReferenceRepository.getGroupsWithEntries
getGroupsWithEntriesForRange()
getGroupsWithEntriesForRange(
startVerseId,endVerseId):CrossReferenceGroupWithEntries[]
Defined in: Data/Repositories/CrossReferenceRepository.ts:212
Bulk variant: get every group (with entries) whose source anchor overlaps
the inclusive range. Used by chapter aggregation services to avoid the
N+1 query pattern of calling getGroupsWithEntries per verse.
Groups are returned in (verse_id_start, sort_order) order; entries within each
group are returned in sort_order to match the legacy generation script.
Parameters
startVerseId
number
endVerseId
number
Returns
CrossReferenceGroupWithEntries[]
Implementation of
ICrossReferenceRepository.getGroupsWithEntriesForRange
getModuleInfo()
getModuleInfo():
CrossReferenceModuleInfo|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
CrossReferenceModuleInfo | undefined
Implementation of
ICrossReferenceRepository.getModuleInfo
Inherited from
BaseModuleRepository.getModuleInfo
getReverseReferences()
getReverseReferences(
verseId):ReverseReference[]
Defined in: Data/Repositories/CrossReferenceRepository.ts:308
Parameters
verseId
number
Returns
Implementation of
ICrossReferenceRepository.getReverseReferences
getReverseReferencesForRange()
getReverseReferencesForRange(
startVerseId,endVerseId):RangeReverseReference[]
Defined in: Data/Repositories/CrossReferenceRepository.ts:269
Bulk variant of getReverseReferences: every citing reference for any verse in the inclusive range, tagged with the target it cites.
Study mode's "Cited in" row asked this per verse per module — ~31 IPC round trips and 31 queries for one chapter of one module.
Parameters
startVerseId
number
endVerseId
number
Returns
Implementation of
ICrossReferenceRepository.getReverseReferencesForRange
getVerseLinksForGroup()
getVerseLinksForGroup(
groupId):VerseLinkRecord[]
Defined in: Data/Repositories/CrossReferenceRepository.ts:149
Target passages of a phrase group, from the unified verse_link table
(source_type='cross_reference_group', link_type='cross_reference').
Empty on a v1 module, where the targets live in cross_reference_entry —
use getEntriesForGroup for version-agnostic access.
Parameters
groupId
number
Returns
Implementation of
ICrossReferenceRepository.getVerseLinksForGroup
hasUnifiedVerseLinks()
hasUnifiedVerseLinks():
boolean
Defined in: Data/Repositories/CrossReferenceRepository.ts:160
True when this module stores its targets in the unified verse_link table.
Answers "where does this module keep its data", so it reports the path the
reads actually take — a module with an empty verse_link alongside a
populated cross_reference_entry is false here, not true.
Returns
boolean