Class: BookRepository
Defined in: Data/Repositories/BookRepository.ts:39
Repository for Book module databases (book_*.db)
This repository handles ALL operations for a book database:
- Module information (metadata about the book)
- Book sections (hierarchical table of contents and content)
- Scripture references (verses mentioned in the book)
Example
const bookDb = new SqliteProvider('data/modules/book_theology.db');
const repo = new BookRepository(bookDb);
// Get module info
const info = repo.getModuleInfo();
console.log(info.getDisplayName()); // "Systematic Theology by Louis Berkhof"
// Get table of contents
const topSections = repo.getTopLevelSections();
Extends
Implements
Constructors
Constructor
new BookRepository(
sql):BookRepository
Defined in: Data/Repositories/BookRepository.ts:42
Parameters
sql
Returns
BookRepository
Overrides
BaseModuleRepository.constructor
Methods
createScriptureReference()
createScriptureReference(
reference):ScriptureReference
Defined in: Data/Repositories/BookRepository.ts:572
Create a scripture reference.
Writes to the unified verse_link table on a v2 module; falls back to the
legacy scripture_reference table on a v1 module so locally-built modules
still import. Pass-2 deletion point for the fallback.
Parameters
reference
Returns
Implementation of
IBookRepository.createScriptureReference
createSection()
createSection(
section):BookSection
Defined in: Data/Repositories/BookRepository.ts:506
Create a new book section
Parameters
section
Returns
Implementation of
deleteScriptureReference()
deleteScriptureReference(
referenceId):boolean
Defined in: Data/Repositories/BookRepository.ts:612
Delete a scripture reference (by link_id on v2, reference_id on v1).
Parameters
referenceId
number
Returns
boolean
Implementation of
IBookRepository.deleteScriptureReference
deleteSection()
deleteSection(
sectionId):boolean
Defined in: Data/Repositories/BookRepository.ts:557
Delete a book section (and all its children via CASCADE)
Parameters
sectionId
number
Returns
boolean
Implementation of
getAllSections()
getAllSections():
BookSection[]
Defined in: Data/Repositories/BookRepository.ts:173
Get all sections (for tree view or search)
Returns
Implementation of
IBookRepository.getAllSections
getAllSectionSummaries()
getAllSectionSummaries():
BookSectionSummary[]
Defined in: Data/Repositories/BookRepository.ts:185
Get all section summaries (lighter weight for tree view)
Returns
Implementation of
IBookRepository.getAllSectionSummaries
getModuleInfo()
getModuleInfo():
BookModuleInfo|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
BookModuleInfo | undefined
Implementation of
Inherited from
BaseModuleRepository.getModuleInfo
getNextSection()
getNextSection(
currentSectionId):BookSection|undefined
Defined in: Data/Repositories/BookRepository.ts:229
Get the next section in reading order (depth-first traversal)
Parameters
currentSectionId
number
Returns
BookSection | undefined
Implementation of
IBookRepository.getNextSection
getParentSection()
getParentSection(
currentSectionId):BookSection|undefined
Defined in: Data/Repositories/BookRepository.ts:317
Get the parent section of the current section
Parameters
currentSectionId
number
Returns
BookSection | undefined
Implementation of
IBookRepository.getParentSection
getPreviousSection()
getPreviousSection(
currentSectionId):BookSection|undefined
Defined in: Data/Repositories/BookRepository.ts:272
Get the previous section in reading order
Parameters
currentSectionId
number
Returns
BookSection | undefined
Implementation of
IBookRepository.getPreviousSection
getScriptureReferences()
getScriptureReferences(
sectionId):ScriptureReference[]
Defined in: Data/Repositories/BookRepository.ts:337
Get all scripture references mentioned in a specific section.
v2 reads the unified verse_link table (source_type='book_section').
v1 COMPAT: reads the legacy scripture_reference table. Pass-2 deletion
point for the fallback.
Parameters
sectionId
number
Returns
Implementation of
IBookRepository.getScriptureReferences
getScriptureReferencesForRange()
getScriptureReferencesForRange(
startVerseId,endVerseId):ScriptureReference[]
Defined in: Data/Repositories/BookRepository.ts:479
Get all scripture references for a verse range.
Reads verse_link on v2 modules, scripture_reference on v1.
Parameters
startVerseId
number
endVerseId
number
Returns
Implementation of
IBookRepository.getScriptureReferencesForRange
getSection()
getSection(
sectionId):BookSection|undefined
Defined in: Data/Repositories/BookRepository.ts:134
Get a book section by ID
Parameters
sectionId
number
Returns
BookSection | undefined
Implementation of
getSectionsByParent()
getSectionsByParent(
parentSectionId):BookSection[]
Defined in: Data/Repositories/BookRepository.ts:159
Get all child sections of a parent section
Parameters
parentSectionId
number
Returns
Implementation of
IBookRepository.getSectionsByParent
getSectionsReferencingVerse()
getSectionsReferencingVerse(
verseId):BookSection[]
Defined in: Data/Repositories/BookRepository.ts:366
Get all sections that reference a specific verse.
Reads verse_link on v2 modules, scripture_reference on v1.
Parameters
verseId
number
Returns
Implementation of
IBookRepository.getSectionsReferencingVerse
getTopLevelSections()
getTopLevelSections():
BookSection[]
Defined in: Data/Repositories/BookRepository.ts:146
Get all top-level sections (sections with no parent)
Returns
Implementation of
IBookRepository.getTopLevelSections
getVerseLinksForSection()
getVerseLinksForSection(
sectionId):VerseLinkRecord[]
Defined in: Data/Repositories/BookRepository.ts:358
Get all verse links carried by a section, in the unified v2 shape. Empty on a v1 module — use getScriptureReferences for version-agnostic access.
Parameters
sectionId
number
Returns
Implementation of
IBookRepository.getVerseLinksForSection
getVerseReferencesWithSections()
getVerseReferencesWithSections(
verseId):object[]
Defined in: Data/Repositories/BookRepository.ts:437
Get scripture references for a verse with their section titles. Used by VerseLinksService to display book references without N+1 queries.
Parameters
verseId
number
Returns
object[]
Implementation of
IBookRepository.getVerseReferencesWithSections
getVerseReferencesWithSectionsForRange()
getVerseReferencesWithSectionsForRange(
startVerseId,endVerseId):object[]
Defined in: Data/Repositories/BookRepository.ts:398
Bulk variant of getVerseReferencesWithSections: every reference whose passage overlaps the inclusive range, each carrying its own passage bounds so the caller can attribute it to the individual verses it covers.
Parameters
startVerseId
number
endVerseId
number
Returns
object[]
Implementation of
IBookRepository.getVerseReferencesWithSectionsForRange
searchSections()
searchSections(
query,options?):BookSection[]
Defined in: Data/Repositories/BookRepository.ts:207
Search book sections using full-text search
Parameters
query
string
options?
limit?
number
Returns
Implementation of
IBookRepository.searchSections
updateModuleInfo()
updateModuleInfo(
info):void
Defined in: Data/Repositories/BookRepository.ts:104
Update the module information
Parameters
info
Returns
void
Implementation of
IBookRepository.updateModuleInfo
updateSection()
updateSection(
section):BookSection
Defined in: Data/Repositories/BookRepository.ts:529
Update an existing book section