Skip to main content

Class: VerseLinkRepository

Defined in: Data/Repositories/VerseLinkRepository.ts:36

Repository for the unified verse_link table (Module Format v2, WS-3).

Works against any connection — module database or user database — because the table is identical everywhere. Reads degrade to empty results when the table is absent (i.e. on every shipped v1 database); writes throw, because silently discarding a link would lose data.

Example

const links = new VerseLinkRepository(mhcDb);
if (links.isSupported()) {
const refs = links.getForSource('commentary_entry', entryId);
}

Implements

Constructors

Constructor

new VerseLinkRepository(sql): VerseLinkRepository

Defined in: Data/Repositories/VerseLinkRepository.ts:39

Parameters

sql

ISql

Returns

VerseLinkRepository

Methods

create()

create(link): VerseLinkRecord

Defined in: Data/Repositories/VerseLinkRepository.ts:162

Insert one link. Validates source_type and link_type.

Parameters

VerseLinkRecord

Returns

VerseLinkRecord

Implementation of

IVerseLinkRepository.create


createMany()

createMany(links): void

Defined in: Data/Repositories/VerseLinkRepository.ts:190

Insert many links in a single transaction.

Parameters

VerseLinkRecord[]

Returns

void

Implementation of

IVerseLinkRepository.createMany


delete()

delete(linkId): boolean

Defined in: Data/Repositories/VerseLinkRepository.ts:209

Delete a single link by id.

Parameters

linkId

number

Returns

boolean

Implementation of

IVerseLinkRepository.delete


deleteForSource()

deleteForSource(sourceType, sourceId): number

Defined in: Data/Repositories/VerseLinkRepository.ts:200

Delete every link belonging to a source row. Returns rows removed.

Parameters

sourceType

"journal" | "prayer" | "verse" | "note" | "dictionary_entry" | "book_section" | "commentary_entry" | "devotional_entry" | "topic" | "cross_reference_group" | "entity_facet"

sourceId

number

Returns

number

Implementation of

IVerseLinkRepository.deleteForSource


getForSource()

getForSource(sourceType, sourceId): VerseLinkRecord[]

Defined in: Data/Repositories/VerseLinkRepository.ts:64

All links belonging to one source row, in sort_order.

Parameters

sourceType

"journal" | "prayer" | "verse" | "note" | "dictionary_entry" | "book_section" | "commentary_entry" | "devotional_entry" | "topic" | "cross_reference_group" | "entity_facet"

sourceId

number

Returns

VerseLinkRecord[]

Implementation of

IVerseLinkRepository.getForSource


getForSources()

getForSources(sourceType, sourceIds): Map<number, VerseLinkRecord[]>

Defined in: Data/Repositories/VerseLinkRepository.ts:76

Batch variant of getForSource. Returns a map keyed by source_id; sources with no links are absent from the map.

Parameters

sourceType

"journal" | "prayer" | "verse" | "note" | "dictionary_entry" | "book_section" | "commentary_entry" | "devotional_entry" | "topic" | "cross_reference_group" | "entity_facet"

sourceIds

number[]

Returns

Map<number, VerseLinkRecord[]>

Implementation of

IVerseLinkRepository.getForSources


getForVerse()

getForVerse(verseId, filter?): VerseLinkRecord[]

Defined in: Data/Repositories/VerseLinkRepository.ts:101

All links whose inclusive range covers verseId.

Parameters

verseId

number

filter?

VerseLinkFilter

Returns

VerseLinkRecord[]

Implementation of

IVerseLinkRepository.getForVerse


getForVerseRange()

getForVerseRange(startVerseId, endVerseId, filter?): VerseLinkRecord[]

Defined in: Data/Repositories/VerseLinkRepository.ts:105

All links whose inclusive range overlaps [startVerseId, endVerseId].

Parameters

startVerseId

number

endVerseId

number

filter?

VerseLinkFilter

Returns

VerseLinkRecord[]

Implementation of

IVerseLinkRepository.getForVerseRange


getSourceIdsForVerse()

getSourceIdsForVerse(sourceType, verseId): number[]

Defined in: Data/Repositories/VerseLinkRepository.ts:140

Distinct source_ids of a given kind that reference verseId.

Parameters

sourceType

"journal" | "prayer" | "verse" | "note" | "dictionary_entry" | "book_section" | "commentary_entry" | "devotional_entry" | "topic" | "cross_reference_group" | "entity_facet"

verseId

number

Returns

number[]

Implementation of

IVerseLinkRepository.getSourceIdsForVerse


hasLinksFor()

hasLinksFor(sourceType): boolean

Defined in: Data/Repositories/VerseLinkRepository.ts:47

True when verse_link actually carries rows for sourceType.

isSupported answers a question about shape — is the table there — which is not the same question as "are this module's links stored here". A half-upgraded module can have both: xref_tsk.db ships an empty verse_link alongside a fully populated v1 cross_reference_entry, so a caller that branches on isSupported() alone reads the empty table and reports no links at all. Branch on this instead when a v1 fallback exists.

Parameters

sourceType

"journal" | "prayer" | "verse" | "note" | "dictionary_entry" | "book_section" | "commentary_entry" | "devotional_entry" | "topic" | "cross_reference_group" | "entity_facet"

Returns

boolean

Implementation of

IVerseLinkRepository.hasLinksFor


isSupported()

isSupported(): boolean

Defined in: Data/Repositories/VerseLinkRepository.ts:43

True when the connected database actually has a unified verse_link table.

Returns

boolean

Implementation of

IVerseLinkRepository.isSupported