Class: CollectionService
Defined in: Services/CollectionService.ts:25
Service for managing collections (folders of bookmarked verses/passages).
Provides higher-level operations on top of the collection repository, including automatic "Favorites" collection creation, duplicate detection, circular reference prevention, and human-readable reference formatting.
Example
const service = new CollectionService(collectionRepo, bibleBookRepo);
// Quick-bookmark a verse to Favorites
await service.quickBookmarkVerse(43003016); // John 3:16
// Create a custom collection and add verses
const collectionId = service.createCollection("Sermon Notes", undefined, "#FF5733");
service.addVerseToCollection(collectionId, 45008028); // Romans 8:28
Constructors
Constructor
new CollectionService(
collectionRepo,bibleBookRepo):CollectionService
Defined in: Services/CollectionService.ts:26
Parameters
collectionRepo
bibleBookRepo
Returns
CollectionService
Methods
addPassageToCollection()
addPassageToCollection(
collectionId,verseIdStart,verseIdEnd,moduleId?,title?,notes?):number
Defined in: Services/CollectionService.ts:312
Add a passage to a collection
Parameters
collectionId
number
verseIdStart
number
verseIdEnd
number
moduleId?
number
title?
string
notes?
string
Returns
number
addVerseToCollection()
addVerseToCollection(
collectionId,verseId,moduleId?,title?,notes?):number
Defined in: Services/CollectionService.ts:272
Add a verse to a specific collection. Prevents duplicate entries (same verse + module) in the same collection.
Parameters
collectionId
number
Target collection ID
verseId
number
The calculated verse ID to add
moduleId?
number
Optional module ID to scope the bookmark to a translation
title?
string
Optional display title
notes?
string
Optional notes to attach to the bookmarked verse
Returns
number
The newly created pinned item ID
Throws
Error if the verse is already in this collection with the same moduleId
bulkAddVersesToCollection()
bulkAddVersesToCollection(
collectionId,verseIds,moduleId?):number[]
Defined in: Services/CollectionService.ts:347
Bulk-add multiple verses to a collection, silently skipping duplicates.
Parameters
collectionId
number
Target collection ID
verseIds
number[]
Array of verse IDs to add
moduleId?
number
Optional module ID applied to all bookmarks
Returns
number[]
Array of pinned item IDs for successfully added verses
createCollection()
createCollection(
name,parentId?,color?,icon?,description?):number
Defined in: Services/CollectionService.ts:129
Create a new collection with validation.
Validates the name is non-empty, checks for circular parent references, and automatically assigns the next sort order among siblings.
Parameters
name
string
Collection name (will be trimmed)
parentId?
number
Optional parent collection ID for nesting
color?
string
Optional hex color code for UI display (e.g., "#FF5733")
icon?
string
Optional emoji or icon identifier
description?
string
Optional description text
Returns
number
The newly created collection ID
Throws
Error if name is empty or parentId creates a circular reference
deleteCollection()
deleteCollection(
collectionId):void
Defined in: Services/CollectionService.ts:186
Delete a collection (will cascade delete all pinned items)
Parameters
collectionId
number
Returns
void
formatPassageReference()
formatPassageReference(
verseIdStart,verseIdEnd):string
Defined in: Services/CollectionService.ts:406
Format a passage reference (e.g., "Romans 8:28-39")
Parameters
verseIdStart
number
verseIdEnd
number
Returns
string
formatVerseReference()
formatVerseReference(
verseId):string
Defined in: Services/CollectionService.ts:392
Format a verse reference for display (e.g., "John 3:16")
Parameters
verseId
number
Returns
string
getCollectionTreeWithCounts()
getCollectionTreeWithCounts():
Collection[]
Defined in: Services/CollectionService.ts:229
Get the full collection tree with item counts
Returns
getOrCreateFavorites()
getOrCreateFavorites():
Collection
Defined in: Services/CollectionService.ts:199
Get or create the default "Favorites" collection
Returns
initializeDefaultCollections()
initializeDefaultCollections():
void
Defined in: Services/CollectionService.ts:455
Initialize default collections on first run
Returns
void
isVerseBookmarked()
isVerseBookmarked(
verseId):boolean
Defined in: Services/CollectionService.ts:109
Check if a verse is bookmarked in any collection
Parameters
verseId
number
Returns
boolean
moveToCollection()
moveToCollection(
pinId,targetCollectionId):void
Defined in: Services/CollectionService.ts:370
Move pinned item to different collection
Parameters
pinId
number
targetCollectionId
number
Returns
void
quickBookmarkPassage()
quickBookmarkPassage(
verseIdStart,verseIdEnd,moduleId?,title?):Promise<number>
Defined in: Services/CollectionService.ts:72
Quick-bookmark a passage (range of verses) to the default "Favorites" collection. Creates the Favorites collection automatically if it does not yet exist.
Parameters
verseIdStart
number
Starting verse ID of the passage
verseIdEnd
number
Ending verse ID of the passage
moduleId?
number
Optional module ID for a specific Bible translation
title?
string
Optional display title
Returns
Promise<number>
The newly created pinned item ID
quickBookmarkVerse()
quickBookmarkVerse(
verseId,moduleId?,title?):Promise<number>
Defined in: Services/CollectionService.ts:42
Quick-bookmark a single verse to the default "Favorites" collection. Creates the Favorites collection automatically if it does not yet exist.
Parameters
verseId
number
The calculated verse ID (e.g., 43003016 for John 3:16)
moduleId?
number
Optional module ID to associate the bookmark with a specific Bible translation
title?
string
Optional display title; if omitted, the formatted reference is used
Returns
Promise<number>
The newly created pinned item ID
removeVerseBookmark()
removeVerseBookmark(
verseId):void
Defined in: Services/CollectionService.ts:97
Remove a verse bookmark from all collections
Parameters
verseId
number
Returns
void
updateCollection()
updateCollection(
collection):void
Defined in: Services/CollectionService.ts:167
Update collection with validation
Parameters
collection
Returns
void