Skip to main content

Class: DictionaryRepository

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

Repository for Dictionary module databases (dictionary_*.db)

This repository handles ALL operations for a dictionary/lexicon database:

  • Module information (metadata about the dictionary)
  • Dictionary entries (definitions, word studies, etc.)
  • Word occurrences (for concordances)

Example

const strongsDb = new SqliteProvider('data/modules/dictionary_strongs.db');
const repo = new DictionaryRepository(strongsDb);

// Get module info
const info = repo.getModuleInfo();
console.log(info.isStrongsConcordance()); // true

// Look up a Strong's number
const entry = repo.getEntryByKey('G25'); // agapao - love
console.log(entry?.definition);

Extends

Implements

Constructors

Constructor

new DictionaryRepository(sql): DictionaryRepository

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

Parameters

sql

ISql

Returns

DictionaryRepository

Overrides

BaseModuleRepository.constructor

Methods

browseByLetter()

browseByLetter(letter, limit, offset): object

Defined in: Data/Repositories/DictionaryRepository.ts:399

Parameters

letter

string | null

limit

number

offset

number

Returns

object

entries

entries: object[]

total

total: number

Implementation of

IDictionaryRepository.browseByLetter


createEntry()

createEntry(entry): DictionaryEntry

Defined in: Data/Repositories/DictionaryRepository.ts:270

Create a new dictionary entry

Parameters

entry

DictionaryEntry

Returns

DictionaryEntry

Implementation of

IDictionaryRepository.createEntry


deleteEntry()

deleteEntry(entryId): boolean

Defined in: Data/Repositories/DictionaryRepository.ts:336

Delete a dictionary entry

Parameters

entryId

number

Returns

boolean

Implementation of

IDictionaryRepository.deleteEntry


getAdjacentEntries()

getAdjacentEntries(entryKey): object

Defined in: Data/Repositories/DictionaryRepository.ts:422

Parameters

entryKey

string

Returns

object

next

next: { entryKey: string; word: string; } | null

prev

prev: { entryKey: string; word: string; } | null

Implementation of

IDictionaryRepository.getAdjacentEntries


getAllEntries()

getAllEntries(options?): DictionaryEntry[]

Defined in: Data/Repositories/DictionaryRepository.ts:180

Get all entries

Parameters

options?
limit?

number

offset?

number

Returns

DictionaryEntry[]

Implementation of

IDictionaryRepository.getAllEntries


getEntriesReferencingVerse()

getEntriesReferencingVerse(verseId): DictionaryEntry[]

Defined in: Data/Repositories/DictionaryRepository.ts:114

Entries that cite a given verse.

Only answerable on a v2 module: on v1 the citations live inside an unindexed JSON column, so this returns an empty array there rather than table-scanning and parsing every entry.

Parameters

verseId

number

Returns

DictionaryEntry[]

Implementation of

IDictionaryRepository.getEntriesReferencingVerse


getEntry()

getEntry(entryId): DictionaryEntry | undefined

Defined in: Data/Repositories/DictionaryRepository.ts:133

Get a dictionary entry by ID

Parameters

entryId

number

Returns

DictionaryEntry | undefined

Implementation of

IDictionaryRepository.getEntry


getEntryByKey()

getEntryByKey(entryKey): DictionaryEntry | undefined

Defined in: Data/Repositories/DictionaryRepository.ts:146

Get a dictionary entry by key (e.g., "G25", "Love", "Baptism") Attempts exact match first, then case-insensitive, then hyphenation variants

Parameters

entryKey

string

Returns

DictionaryEntry | undefined

Implementation of

IDictionaryRepository.getEntryByKey


getEntryCount()

getEntryCount(): number

Defined in: Data/Repositories/DictionaryRepository.ts:438

Returns

number

Implementation of

IDictionaryRepository.getEntryCount


getExampleVerses()

getExampleVerses(entryId): ExampleVerse[]

Defined in: Data/Repositories/DictionaryRepository.ts:90

Example verses for an entry.

v2 reads the unified verse_link table (source_type='dictionary_entry'). v1 COMPAT: falls back to the JSON example_verses column on the entry row. Pass-2 deletion point for the fallback.

Parameters

entryId

number

Returns

ExampleVerse[]

Implementation of

IDictionaryRepository.getExampleVerses


getLetterIndex()

getLetterIndex(): object[]

Defined in: Data/Repositories/DictionaryRepository.ts:385

Returns

object[]

Implementation of

IDictionaryRepository.getLetterIndex


getModuleInfo()

getModuleInfo(): DictionaryModuleInfo | 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

DictionaryModuleInfo | undefined

Implementation of

IDictionaryRepository.getModuleInfo

Inherited from

BaseModuleRepository.getModuleInfo


getOccurrences()

getOccurrences(entryKey): WordOccurrence[]

Defined in: Data/Repositories/DictionaryRepository.ts:358

Get all occurrences of a word (by entry key).

Note: word_occurrence is optional — most shipped dictionaries are not concordances and omit the table entirely, in which case this throws no such table: word_occurrence. That behaviour predates Module Format v2 and is asserted by DictionaryRepository.test.ts, so it is deliberately left unchanged here; callers must guard with SchemaCompat.for(sql).hasTable('word_occurrence').

Parameters

entryKey

string

Returns

WordOccurrence[]

Implementation of

IDictionaryRepository.getOccurrences


getOccurrencesForVerse()

getOccurrencesForVerse(verseId): WordOccurrence[]

Defined in: Data/Repositories/DictionaryRepository.ts:372

Get occurrences for a specific verse. Throws when the optional word_occurrence table is absent — see getOccurrences.

Parameters

verseId

number

Returns

WordOccurrence[]

Implementation of

IDictionaryRepository.getOccurrencesForVerse


getVerseLinksForEntry()

getVerseLinksForEntry(entryId): VerseLinkRecord[]

Defined in: Data/Repositories/DictionaryRepository.ts:103

Verse links for an entry in the unified v2 shape. Empty on a v1 module.

Parameters

entryId

number

Returns

VerseLinkRecord[]

Implementation of

IDictionaryRepository.getVerseLinksForEntry


searchByTitle()

searchByTitle(query, options?): DictionaryEntry[]

Defined in: Data/Repositories/DictionaryRepository.ts:246

Search dictionary entries by title (word/entry_key) only

Parameters

query

string

options?
limit?

number

Returns

DictionaryEntry[]

Implementation of

IDictionaryRepository.searchByTitle


searchEntries()

searchEntries(query, options?): DictionaryEntry[]

Defined in: Data/Repositories/DictionaryRepository.ts:199

Search dictionary entries by title first, then by full text.

The full-text index covers word, definition and usage_notes, and BM25 happily ranks a passing mention in a long definition above the entry actually titled with the search word. With a LIMIT applied, looking up "Moses" in a dictionary that plainly has a MOSES entry returned thirty other articles and not that one. Title matches are what someone typing a word into a dictionary means, so they lead; full-text hits fill the rest.

Parameters

query

string

options?
limit?

number

Returns

DictionaryEntry[]

Implementation of

IDictionaryRepository.searchEntries


updateEntry()

updateEntry(entry): DictionaryEntry

Defined in: Data/Repositories/DictionaryRepository.ts:301

Update an existing dictionary entry

Parameters

entry

DictionaryEntry

Returns

DictionaryEntry

Implementation of

IDictionaryRepository.updateEntry


updateModuleInfo()

updateModuleInfo(info): void

Defined in: Data/Repositories/DictionaryRepository.ts:55

Update the module information.

dictionary_type is validated here rather than by a SQL CHECK (WS-7): the constraint was dropped because the set is open, so this is the enforcement point.

Parameters

info

DictionaryModuleInfo

Returns

void

Implementation of

IDictionaryRepository.updateModuleInfo